我正在尝试执行以下代码以使用 vb.net 从 infopath 表单调用 sql 过程,我调试并检查了错误,但代码正在正确执行,并且在检索执行过程后收到的输出消息时遇到问题。
请帮我尽快解决这些问题
谢谢
Try
Dim con As New SqlConnection("Data Source= XXXX;Initial Catalog= XXXXX;Integrated Security=true")
Dim cmd As New SqlCommand
Dim dr As SqlDataReader
con.Open()
cmd.CommandType = Data.CommandType.StoredProcedure
cmd.CommandText = "Procedure Name"
cmd.Parameters.Add(New SqlParameter("@Name", SqlDbType.VarChar, 50)).Value = "XXX"
cmd.Parameters.Add(New SqlParameter("@CustID", SqlDbType.VarChar, 20)).Value = "XXX"
cmd.Connection = con
dr = cmd.Executereader()
dr.Read()
If dr.HasRows Then
MessageBox.Show(dr.GetString(0))
End If
con.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
我的 Sql 程序:
enter code here
Create procedure Test_Infopath
@Name varchar(50),
@CustID Varchar(20)
AS
Declare @Condition INT
SELECT @Condition = CustID FROM temp_infopath WHERE CustID = @CustID
IF @CustID= @Condition
BEGIN
Print 'Customer ID already Exists'
END
Else
Print 'Submit the form to insert the data'