Public Function SelectOleDbSrvRows(dataSet As DataSet, connection As String, query As String) As DataSet
Dim conn As New OleDbConnection(connection)
Dim adapter As New OleDbDataAdapter()
adapter.SelectCommand = new OleDbCommand(query, conn)
adapter.Fill(dataset)
Return dataset
End Function
[C#語言]
public DataSet SelectOleDbSrvRows(DataSet dataset,string connection,string query)
{
OleDbConnection conn = new OleDbConnection(connection);
OleDbDataAdapter adapter = new OleDbDataAdapter();
adapter.SelectCommand = new OleDbCommand(query, conn);
adapter.Fill(dataset);
return dataset;
}
當使用SqlDataReaderd對象時,使用方法為:
[Visual Basic語言]
Public Function SelectSqlSrvRows(dataSet As DataSet, connection As String, query As String) As DataSet
Dim conn As New SqlConnection(connection)
Dim adapter As New SqlDataAdapter()
adapter.SelectCommand = new SqlCommand(query, conn)
adapter.Fill(dataset)
Return dataset
End Function
[C#語言]
public DataSet SelectSqlSrvRows(DataSet dataset,string connection,string query)
{
SqlConnection conn = new SqlConnection(connection);
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = new SqlCommand(query, conn);
adapter.Fill(dataset);
return dataset;
}