Dataadapter
-
-
Hi all Can i retrieve selected tables from the database using one adapter,command object without going for a storedprocedure.I dont want to retreive the entire tables in to datasource....if any one finds solution pls email me .;) With Many Thanks kiran
Yes, we can give Select criteira when filling DataSet using DataAdapter. In fact, we dont even need a Command object. We can just give a "SELECT String" and a Connection which need not be open but initialised. DataAdapter will open the Connection and fill the dataset using that connection and immediately closes the Connection, if the Connection was not opened earlier. Here is a simple code ( plz check for the syntax ) Dim cn as SqlConnection = new SqlConnection ( "Connection String") Dim da as SqlDataAdapter = new SqlDataAdapter( "Select * from Table", cn ) da.Fill(ds) Bhaskara
-
Yes, we can give Select criteira when filling DataSet using DataAdapter. In fact, we dont even need a Command object. We can just give a "SELECT String" and a Connection which need not be open but initialised. DataAdapter will open the Connection and fill the dataset using that connection and immediately closes the Connection, if the Connection was not opened earlier. Here is a simple code ( plz check for the syntax ) Dim cn as SqlConnection = new SqlConnection ( "Connection String") Dim da as SqlDataAdapter = new SqlDataAdapter( "Select * from Table", cn ) da.Fill(ds) Bhaskara
Hi Thanks for your response.......but wen u specify datasource in ur connection string like pubs u get the entire tables and also we want only selected tables like employer,customers etc with only one dataadapter object. I hope u understand my problem..regarding the performance. kiran With Many Thanks kiran
-
Hi Thanks for your response.......but wen u specify datasource in ur connection string like pubs u get the entire tables and also we want only selected tables like employer,customers etc with only one dataadapter object. I hope u understand my problem..regarding the performance. kiran With Many Thanks kiran
try this da.selectcommand = "select * from employer; select * from customers" and fill the dataset Bhaskara