Use namespace System.Data.OleDb VB.NET
Dim myConnection As New OleDbConnection('Provider=SQLOLEDB.1;Data Source=localhost;database=northwind;User Id=sa;Password=;')
Dim myda As New OleDbDataAdapter('Select * from Orders', myConnection)
Dim ds = New DataSet
myda.Fill(ds, 'table')
Dim dr() As DataRow
Dim id As String = 'ROMEY' ’ 'Field with id ROMEY has more than one records found
Dim sel As String = 'customerid=’' + id + '’'
dr = ds.Tables(0).Select(sel)
Dim i As Integer
For i = 0 To (dr.GetUpperBound(0)) - 1
Response.Write((dr(i)('Orderid').ToString() + ControlChars.Tab + dr(i)('Customerid').ToString() + ControlChars.Tab + dr(i)('Freight').ToString() + '<br>'))
Next
C#
OleDbConnection myConnection = new OleDbConnection('Provider=SQLOLEDB.1;Data Source=localhost;database=northwind;User Id=sa;Password=;');
OleDbDataAdapter myda= new OleDbDataAdapter ('Select * from Orders', myConnection);
System.Data.DataSet ds= new DataSet ();
myda.Fill (ds,'table');
DataRow[] dr ;
string id ='ROMEY';// 'Field with id ROMEY has more than one records found
string sel ='customerid=’'+ id + '’';
dr = ds.Tables [0].Select (sel);
int i;
for(i=0;i<dr.GetUpperBound(0);i++)
{
Response.Write (dr[i]['Orderid'].ToString() + '\t' + dr[i]['Customerid'].ToString() + '\t' + dr[i]['Freight'].ToString () + '<br>');
}
Share with