Reputation: 31
I want to know the equivalent of vb recordset in .net?
Which ado.net object can be used to replace vb recordset?
Upvotes: 3
Views: 5316
Reputation: 300529
There is no direct replacement in ADO.NET for a VB6 recordset. It depends what you want to use it for, but candidates are
a Dataset (this is probably the closest match)
or a DataReader
A very basic example would be:
public DataSet GetDataset(string sql, string connectionString)
{
DataSet ds = new DataSet();
using (SqlConnection sqlConn = new SqlConnection(connectionString))
{
using (SqlDataAdapter adapter = new SqlDataAdapter(sql, sqlConn))
{
adapter.Fill(ds);
}
}
return ds;
}
You should also take a look at:
Upvotes: 2