Access 在所有查询之间共享参数,因此无需专门将参数从一个查询传递到另一个查询。
查询 1:
SELECt * FROM Customer WHERe ID > [param1] AND ID < [param2]
查询 2:
SELECt * FROM Query1
VB.NET 代码:
Dim ConnString As String = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=Database.mdb" Dim SqlString As String = "Query2" Using Conn As New OleDbConnection(ConnString) Using Cmd As New OleDbCommand(SqlString, Conn) Cmd.CommandType = CommandType.StoredProcedure Cmd.Parameters.AddWithValue("param1", "1") Cmd.Parameters.AddWithValue("param2", "3") Conn.Open() Using reader As OleDbDataReader = Cmd.ExecuteReader() While reader.Read() Console.WriteLine(reader("ID")) End While End Using End Using End Using
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)