List all the steps in order, to access a database through ado.net?



List all the steps in order, to access a database through ado.net?..

Answer / Jatin Goyal

1. Install .NET Framework and ADO.NET.

2. Create a connection string that specifies the database you want to connect to.

3. Create an instance of SqlConnection and set its ConnectionString property to your connection string.

4. Open the connection using the Open() method on SqlConnection object.

5. Create a command object with your SQL statement (or stored procedure name) by creating an instance of SqlCommand and setting its CommandText property.

6. Execute the command to get data or execute non-query commands using the appropriate method like ExecuteReader(), ExecuteScalar(), etc.

7. Close the connection when you're done.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More ADO.NET Interview Questions

What are the methods of XML dataset object?

1 Answers  


Explain all the classes those are used for database connections between sql server and asp.net?

1 Answers  


Define Execute Reader?

1 Answers  


How To Update A Column In A DataGrid Using C#.NET? I am getting InvalidCastException as (Specified cast is not valid) while updating 2nd column in a datagrid? Id,firstname,lastname are the three columns of my datagrid respectively. I wanted to edit the second column(lastname) and update it. I did the following code in DataGrid's updatecommand(),but failed to update ! Int varid=(int)DataGrid1.DataKeys[e.Item.ItemIndex]; TextBox lnm=(TextBox)e.Item.Cells[2].Controls[0]; string str=lnm.Text ; SqlCommand cmd=new SqlCommand("update customer set lastname='" + str + "' where id=" + varid + "",con); cmd.ExecuteNonQuery(); DataGrid1.EditItemIndex=- 1; DataGrid1.DataBind();

2 Answers   Mind Tree, TCS,


Define executenonquery?

1 Answers  


How many major types of connection objects in ADO.NET?

1 Answers   MCN Solutions,


What are the advantages using ado.net?

1 Answers  


What is ado.net in mvc?

1 Answers  


how to add a selected row of a gridview to another gridview without reloading the page??

2 Answers  


What is aggregating data ?

1 Answers  


How to get the new oledb connection of oracle in database programming?

1 Answers  


How can I retrieve two tables of data at a time by using data reader? Data reader read and forward only, how is it possible to get 2 tables of data at a time?

1 Answers  


Categories