Answer:
System.Data;
System.Data.SqlClient;
SqlConnection sqCon = new SqlConnection(”connection string”);
SqlCommand sqCmd = new SqCmd();
sqCmd.Connection = sqCon;
sqCmd.CommandText = procedure_name;
sqCmd.CommandType = CommandType.StoredProcedure;
sqComd.ExecuteReader();
2. What is maximum length of VARCHAR in SQL-SERVER?
Answer:
VARCHAR[(n)]
Null-terminated Unicode character string of length n, with a maximum of 255 characters. If n is not supplied, then 1 is assumed.
3. What are good ADO.NET object(s) to replace the ADO Recordset object?
Answer:
In ADO, the in-memory representation of data is the recordset.
In ADO.net, it is the dataset
A recordset looks like a single table in ADO
In contrast, a dataset is a collection of one or more tables in ADO.net
ADO is designed primarily for connected access
ADO.net the disconnected access to the database is used
In ADO you communicate with the database by making calls to an OLE DB provider.
In ADO.NET you communicate with the database through a data adapter (an OleDbDataAdapter, SqlDataAdapter, OdbcDataAdapter, or OracleDataAdapter object), which makes calls to an OLE DB provider or the APIs provided by the underlying data source.
In ADO you cant update the database from the recordset.
ADO.NET the data adapter allows you to control how the changes to the dataset are transmitted to the database.
4. How do you get records number from 5 to 15 in a dataset of 100 records? Write code.
Answer:
OleDbConnection1.Open()
OleDbDataAdapter1.Fill(DataSet21, 5, 15, “tab”)
This will fill the dataset with the records starting at 5 to 15
5.