开发者

How to create parameterized queries in vb.net?

开发者 https://www.devze.com 2022-12-13 01:53 出处:网络
Using parameterized queries wit开发者_如何学运维h ms access 2003 integration.To search any data according to different criteria. You\'ll need to use the OleDbConnection class, as well as the OleDbComm

Using parameterized queries wit开发者_如何学运维h ms access 2003 integration. To search any data according to different criteria.


You'll need to use the OleDbConnection class, as well as the OleDbCommand class, with the proper connection string for Access.

Dim sql as String = "SELECT * FROM TABLE_A WHERE COLUMN_A = @PARAM"
Dim connectionString as String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;User Id=admin;Password=;"
Using connection As New OleDbConnection(connectionString)
   Dim command As New OleDbCommand(sql)
   command.Connection = connection
   command.Params.Add("@PARAM", yourVariable)
   connection.Open()
    Dim reader As OleDbDataReader = command.ExecuteReader()
    While reader.Read()
        Console.WriteLine(reader.GetString(1)
    End While
End Using


You may find this helpful: Howto? Parameters and LIKE statement SQL

0

精彩评论

暂无评论...
验证码 换一张
取 消