本文整理汇总了VB.NET中System.Data.SqlClient.SqlParameter类的典型用法代码示例。如果您正苦于以下问题:VB.NET SqlParameter类的具体用法?VB.NET SqlParameter怎么用?VB.NET SqlParameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SqlParameter类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: AddSqlParameters
Public Sub AddSqlParameters()
' ...
' create categoriesDataSet and categoriesAdapter
' ...
categoriesAdapter.SelectCommand.Parameters.Add( _
"@CategoryName", SqlDbType.VarChar, 80).Value = "toasters"
categoriesAdapter.SelectCommand.Parameters.Add( _
"@SerialNum", SqlDbType.Int).Value = 239
categoriesAdapter.Fill(categoriesDataSet)
End Sub
示例2: New SqlParameter
' 导入命名空间
Imports System
Imports System.Collections
Imports System.Data
Imports System.IO
Imports System.Xml.Serialization
Imports System.Windows.Forms
Imports System.Data.SqlClient
Public Class MainClass
Shared Dim WithEvents con As SqlConnection
Shared Sub Main()
con = New SqlConnection("Server=(local)\SQLEXPRESS;Initial Catalog=MyDatabase;Integrated Security=SSPI")
Dim cmd As New SqlCommand("SELECT FirstName, LastName FROM Employee WHERE FirstName = @fn", con)
cmd.Parameters.Add(New SqlParameter("@fn", SqlDbType.VarChar, 10)).Value = "Joe"
Try
con.Open()
Dim reader As SqlDataReader = cmd.ExecuteReader()
While reader.Read()
Console.WriteLine("{0} - {1}", reader.GetString(0), reader.GetString(1))
End While
reader.Close()
Finally
con.Close()
End Try
End Sub
End Class