数据库开发013VB.NET操作SQL Server带参数的存储过程
程序员文章站
2022-05-07 14:33:24
...
Imports System.Data.SqlClient
Public Class Form1
Dim conn As SqlConnection
Dim comm As SqlCommand
Private Function GetConnection() As SqlConnection
Return New SqlConnection(My.Settings.SalesConnectionString)
End Function
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
conn = GetConnection()
conn.Open()
comm = New SqlCommand("sp_CheckPass", conn)
comm.CommandType = CommandType.StoredProcedure
comm.Parameters.Add("@CHKName", SqlDbType.VarChar, 30).Value = TextBox1.Text
comm.Parameters.Add("@CHKPass", SqlDbType.VarChar, 30).Value = TextBox2.Text
comm.Parameters.Add("@ISValid", SqlDbType.VarChar, 20).Direction = ParameterDirection.Output
comm.ExecuteNonQuery()
If comm.Parameters("@ISValid").Value = "Good" Then
MsgBox("成功")
Else
MsgBox("失败")
End If
conn.Close()
End Sub
End Class
上一篇: 数据库视频-----触发器
下一篇: oracle游标、触发器创建与使用