.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Post New Web Links

Dataset select issue

Posted By:      Posted Date: December 04, 2010    Points: 0   Category :ASP.Net
 

Hi there,

I have written some code using data sets (which i am new to). I have brought back all of the rows, which is fine, but i need to select certain customers according to if they are active

SqlConnection cnn = new SqlConnection(@"Data Source=192.168.100.2;Initial Catalog=intranet;User ID=sa;Password=xxxxx;");
        SqlDataAdapter cmd1 = new SqlDataAdapter("select * from clients WHERE active = 1", cnn);

        DataSet ds = new DataSet();
        cmd1.Fill(ds, "clients");

        SqlDataAdapter cmd2 = new SqlDataAdapter("select * from tbl_imalive", cnn);
        cmd2.Fill(ds, "tbl_imalive");

        ds.Relations.Add("myrelation",
        ds.Tables["clients"].Columns["id"],
        ds.Tables["tbl_imalive"].Columns["customerID"]);

        parentRepeater.DataSource = ds.Tables["clients"];
        Page.DataBind();

&nb


View Complete Post


More Related Resource Links

SQL Server 2008 Linked Server SELECT INTO issue

  
I have a SQL Server 2008 installation running on a clustered Windows Server 2008 R2. I am trying to execute a query on a remote SQL Server to create a table. In order to do so, I call a stored procedure on the remote SQL Server. The stored procedure's description is as follows: ------------------------------------- Create procedure [dbo].[USP_RemoteExec] @varSQL varchar(max) as declare @tempSql nvarchar(max); set @tempSql = CONVERT(nvarchar(max),@varSQL); exec sp_executesql @tempSql ------------------------------------- I pass the following command to the remote stored procedure as follows: exec [servername].[dbname].dbo.USP_RemoteExecute @varSQL='if object_id(''testdb.dbo.tmp_testEmpty3'') is not null drop table testdb.dbo.tmp_testEmpty3; create table testdb.dbo.tmp_testempty3(col1 int, col2 varchar(20));' go select * from [servername].testdb.dbo.tmp_testEmpty3 go This statement returns the following: --------------------------------- col1,col2 (0 row(s) affected) But, when I run the following statement: exec [servername].[dbname].dbo.USP_RemoteExecute @varSQL='if object_id(''testdb.dbo.tmp_testEmpty'') is not null drop table testdb.dbo.tmp_testEmpty; select * into testdb.dbo.tmp_testEmpty from (select top 10 mytab.[col1] as [col1] , mytab.[col2] as [col2] , mytab.[col3] as [col3] FROM testdb.dbo.mytab as [mytab] with (nolock)) as A' go select * from [

SQL Server 2008 Linked Server SELECT INTO issue

  
I have a SQL Server 2008 installation running on a clustered Windows Server 2008 R2. I am trying to execute a query on a remote SQL Server to create a table. In order to do so, I call a stored procedure on the remote SQL Server. The stored procedure's description is as follows: ------------------------------------- Create procedure [dbo].[USP_RemoteExec] @varSQL varchar(max) as declare @tempSql nvarchar(max); set @tempSql = CONVERT(nvarchar(max),@varSQL); exec sp_executesql @tempSql ------------------------------------- I pass the following command to the remote stored procedure as follows: exec [servername].[dbname].dbo.USP_RemoteExecute @varSQL='if object_id(''testdb.dbo.tmp_testEmpty3'') is not null drop table testdb.dbo.tmp_testEmpty3; create table testdb.dbo.tmp_testempty3(col1 int, col2 varchar(20));' go select * from [servername].testdb.dbo.tmp_testEmpty3 go This statement returns the following: --------------------------------- col1,col2 (0 row(s) affected) But, when I run the following statement: exec [servername].[dbname].dbo.USP_RemoteExecute @varSQL='if object_id(''testdb.dbo.tmp_testEmpty'') is not null drop table testdb.dbo.tmp_testEmpty; select * into testdb.dbo.tmp_testEmpty from (select top 10 mytab.[col1] as [col1] , mytab.[col2] as [col2] , mytab.[col3] as [col3] FROM testdb.dbo.mytab as [mytab] with (nolock)) as A' go select * from [

better code for select in a typized dataset

  

hi there
i have a dataset in my project named  DS.xsd
so, i usually take a dataTable using this code:


        Dim da As New DSTableAdapters.RistorantiTableAdapter
        Dim DT As New DataTable("Ristoranti")
        Dim DR As DS.RistorantiRow()

        DR = da.GetData.Select("codRistorante=" & HID_Risto.Value)
        Dim drr As DS.RistorantiRow = DR(0)

        With drr
            If .IsCAPNull = False Then TXT_Cap.Text = .CAP
            If .IsCategoriaNull = False Then TXT_Categoria.Text = .Categoria
......

i think it is obsolete code
and i use 5 rows of code for take my data
is it correct? or may i use another approach for doing it better?


How to select only one row from DataSet

  

Hi,

My DataSet gives a result like this when i bind to GridView


BillNo     BillStation            Amt1         Amt2       Amt3       Amt4

Hyd

 1              Hyd                  100              50          50           25

 2              Hyd                  100              50          50           25

Bang 

 2              Bang                500            100        200           50 

 2              Bang                500            100        200           50

Delhi

 3     &n

SQL & JavaScript - Apostrophe Issue, SELECT statement is not returning any results.

  

Hi,

Any help would be great on this.

I have the following code within an .asp page in JavaScript:

function SDsitecalls1(Sitename)

SQL = "SELECT COUNT(*) FROM [SDADMIN].[SRFILE] WHERE SRSITE = 'Our Lady''s R C Sports College - Hbev' AND SRCOMPLETE=0 AND SRINCOMP=1 AND SR_Group=38;"
 tempval=connection.execute(SQL)
 response.write(tempval(0))
end function

The function is called via the below:

 <td style="width: 114px" class="style65"><a href="/suppdesk/customercalls.asp?customer=BSFMAN&site=Our+Lady''s+R+C+Sports+College"><%=SDsitecalls1("Our Lady's R C Sports College - Hbev")%></a></td> 

When this is ran I do not receive any errors but the SELECT command doesn't return any results (Just a 0). I've tried a few different methods such as using the Parameter SiteName and Single/Double Apostrophes however I either receive an error or blank results.

The function works with all other names however the apostrophe seems to cause issues here. Is there a way to extract the data without editing the SQL?

Thanks very much for the help,

Jas


Performance issue with select query

  

Hi,

I have simple select query as below

SELECT DISTINCT BCEGPrsLinesCd, BCEGCmlLinesCd,CountyFedInfoPrcStdNbr

FROM TPSeleBCEGAddress WITH(nolock)

WHERE LTRIM(RTRIM(ZIPCd))='1000'

AND LTRIM(RTRIM(StateCd))='MI'

AND LTRIM(RTRIM(CITYNM))='AFTON'

AND LTRIM(RTRIM(PrefixStreetDirCd))='E'

AND LTRIM(RTRIM(StreetNm))='OAKGREEN'

AND LTRIM(RTRIM(STREETTYPECD))='S'

AND 1000>= CONVERT(INT,(SUBSTRING(LOWAdrNbr,0,CHARINDEX(' ',LOWAdrNbr))))

AND 1000<= CONVERT(INT,(SUBSTRING(HIGHAdrNbr,0,CHARINDEX(' ',HIGHAdrNbr))))

AND (LTRIM(RTRIM( BCEGOddEvenCd ))='E' or LTRIM(RTRIM( BCEGOddEvenCd ))='B')

AND LTRIM(RTRIM(BCEGEffectiveYr))='1998'

Table TPSeleBCEGAddress has 64 Lakhs records in it and it takes around 22 Seconds to execute this query. Please let me know a way to improve performance of this select query.

Primary key defined on this table comprises of 16 columns.

Regards

Ravindra

 

 

 


huge select issue

  

Hi,

I am having alot of trouble trying to find out how to run a query. I dont know if a view is the best way to go, and if it is which fields to link in within the view.

I have 2 tables, one is 'contacts' and one is 'resume'.

users insert data into the resume table, with their username in the 'User Id' column.

the contacts table is unrelated, but I only want to show table resume data to users if they share a row in the contacts table with the other user and the permissions are a certain amount.

On a page, id like rows from the resume table to show (where User Id = the querystring 'id'), but only show if the signed in user (Profile.UserName) is on a row (in column 'theiruserid') with the url querystring 'id' username (in column 'myuserid'), and that the 'permissions' column of the resume table is '1', or the 'permissions' column of the resume table matches the number in the contacts table (on the row that both usernames are on).

How do i do this?

would a view work? if so, how do i set up this view? which columns need to be linked? and then what select statement can be used?

I have been through so many select statements and different view combinations, thanks so much if you can help





Strange time issue on simple select statement

  

Hi, I have a strange time out issue on a simple select statement.
This is my select statement:

Select * from DyGeJournal where ord>=4609635 and Fracsec>=31

The ord and Fracsec is the primary key.
When I ask for the actual excecution plan, he is using a an index seek.
It takes more than 1,5 minutes to get a result back.

When I shrink my database, everyting is running as expected, the query above runs in milliseconds.
After a while (2 weeks) it start agian running very slow.

I have the same logic on other tables, but I don't have the problem on those tables.
What can cause this problem?


SELECT issue. to show bookings

  

i have the following T-SQL query that will output details of holiday bookings

 SELECT DateFrom, Quantity, Duration -- SUM(Quantity) 

	FROM BookingItem 

	JOIN Booking ON BookingItem.BookingRef = Booking.BookingRef

	WHERE (BookingItemStatusCode IN ('FRM','FRP') OR (BookingItemStatusCode = 'PRV' AND GETDATE() >= DATEADD(DAY, ProvisionalDays, Booking.CreatedDate)))

	AND OptionCode = '2B'

	AND DateFrom BETWEEN '01/JUL/2010' AND '31/DEC/2010'

	AND UnitTypeCode = '5P'

	ORDER 

Dataset.tables.Select method

  

I want to select student who belogs to New York.so this purpose i write query as

ds.Tables("student").select("city==NewYork"); it is not work

where

"ds" is dataset

"city" is column name

"New York" is the string

Can anybody help me? 

Give me suggestion 


AJAX GridView Checkbox Select All in ASP.Net

  
In the previous article GridView Select Multiple Rows you learnt the multiple row selection in GridView control. Here you will get the C# code sample to select all the gridview rows using single checkbox server control. You can highlight the selected rows with different color and Font state Bold. If you want to use the selection values on different ASP.Net

Introducing ADO.NET and the Typed DataSet

  
In reviewing the applications it seemed everything they were doing involved database reads, writes, and manipulation. The development staff had been reviewing the articles and code samples for ADO.NET. They had spent many years refining their existing ADO based infrastructure and perfecting their use of ADO

Create and Use a Typed DataSet by Using Visual C# .NET

  
This article shows you how to create and use a typed DataSet in a small Web application. Typed DataSets, which inherit from the DataSet class, create first-class members of a DataSet's DataTables and DataColumns, yielding the many benefits that come with the use of strong typing.

Get Top 1 Record from Dataset

  
Many of them in need of getting the Top 1 or Top 10 records from a Dataset without going to SQL query. It is possible to do from Code Behind. I have given the code below,
The below code is to get single record from a Dataset. Also I have given for getting 8 records at Green Color.

Returning a DataSet From a Web Services: Step-by-Step

  
This Example Shows how to create a webservice which returns a DataSet and a Client Which displays the DataSet in a Grid.

Description

This Example Shows how to create a webservice which returns a DataSet and a Client Which displays the DataSet in a Grid.

IsapiModule Error 500 Issue

  

I am about exhausted trying to figure out this error:

HTTP Error 500.0 - Internal Server Error

Description: The page cannot be displayed because an internal server error has occurred.

Error Code: 0x8007007b

Notification: ExecuteRequestHandler

Module: IsapiModule

Requested URL: http://localhost:80/ReportServer

Physical Path: c:\Program Files\Microsoft SQL Server\MSSQL.2\Reporting Services\ReportServer

When I enable Failed Request Tracing Rules and view the log output I am supposing that the actual problem is in the 2nd call where there are 2 backslashes before the actual filename in the specified path:

ISAPI_START

CALL_ISAPI_EXTENSION DllName="C:\Windows\Microsoft.NET\Framework\v2.0.50727\\aspnet_isapi.dll"

 

Select value in gridview

  

Hi, I am new to gridview. I want to make a gridview. Its row when selected should direct me to a specific .aspx page.Each row should direct to a different page. Should I use querystrings for this? Please suggest. Regards, ap.


Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend