Hi Arun
you've left out several pieces of information. What dbms are you connecting to (Oracle,SQL Server,Access) so I'm not going to give the line by line breakdown for every one of them. Use the code I give to help you understand how the Active Data Object (ADO.Net) works.
code is in VB.Net
'I'm assuming you're using a SQL Server dbms
'Case 1 --Retrieving a single value
Using System.Data.SqlClient
Dim sqlConn As New SqlClient.SqlConnection 'You need a connection
Dim sqlComm As New SqlClient.SqlCommand 'You 're also going to need a command objectDim ValuetobeRetrieved As String
sqlConn.ConnectionString = "" ' Whatever connection string you're using ie. Data Source=[MachineName];Initial Catalog=[dbName];Integrated Security=[True/False--True=your application has security rights,False=Username and Password has to be supplied for your application to connect]
sqlComm.CommandText = "SELECT [ValueToBeRetrieved] FROM [db_Table] WHERE [Insert Filter criteria] "sqlComm.Connection = sqlConn ' Set the commands connection
sqlConn.Open() 'Self explanatory
ValuetobeRetrieved= sqlComm.ExecuteScalar()
sqlConn.Close()
NOTES: always ensure that your data typing in .Net matches the value type in SQL (String = String etc..)
Also explore and discover the following
Datareader,DataSets,DataGrid, DataGridView
Unfortunately I've run out of time so I cannot continue with Case 2 retrieving and displaying multiple values (a full row in a table for example), but with research and a little curiosity you can discover that for yourself. Have fun!!
Enter your message below
Sign in or Join us (it's free).