Asp.net 如何在一个子系统上使用多个存储过程
我编写了一个代码来检索和显示ASP.NET存储过程中的数据,如下所示Asp.net 如何在一个子系统上使用多个存储过程,asp.net,sql-server,stored-procedures,Asp.net,Sql Server,Stored Procedures,我编写了一个代码来检索和显示ASP.NET存储过程中的数据,如下所示 Private Sub AutoNumberVerification() Dim Conn As New SqlConnection(strConn.ToString) Dim cmd As New SqlCommand() Try cmd.Connection = Conn cmd.CommandType = CommandType.StoredProcedure
Private Sub AutoNumberVerification()
Dim Conn As New SqlConnection(strConn.ToString)
Dim cmd As New SqlCommand()
Try
cmd.Connection = Conn
cmd.CommandType = CommandType.StoredProcedure
Conn.Open()
If (txtProducerID.Text.Trim.Length = 9) Then
cmd.CommandText = "spProductCount"
cmd.Parameters.AddWithValue("@ID", txtProducerID.Text)
End If
Dim da As New SqlDataAdapter(cmd)
Dim dt As New DataTable()
da.Fill(dt)
Dim dr As SqlDataReader = cmd.ExecuteReader()
dt.Load(dr)
If (convertInteger(dt.Rows(0)("estbProducerID").ToString) > 0) Then
cmd.CommandText = "spProductCount"
rdoEstbProducerList.Items.FindByValue(convertInteger(dt.Rows(0)("estbProducerID"))).Selected = True
End If
cmd.CommandText = "spProductCount"
TextBox11.Text = dt.Rows(0)("ALL").ToString
TextBox4.Text = dt.Rows(0)("FOOD").ToString
TextBox5.Text = dt.Rows(0)("DRINKS").ToString
TextBox6.Text = dt.Rows(0)("TAILOR").ToString
TextBox7.Text = dt.Rows(0)("USABLE").ToString
TextBox8.Text = dt.Rows(0)("HERB").ToString
cmd.CommandText = "spProductproveCounts"
TextBox12.Text = dt.Rows(0)("REGISTERED").ToString
Catch ex As Exception
Response.Write("ERROR Load: " & ex.Message)
Finally
Conn.Close()
End Try
End Sub
但它显示一个error=“REGISTERED”不属于该表
如何使用两个存储过程 仅将cmd.CommandText设置为存储过程名称将不会执行它。每次更改CommandText后,仍然需要调用ExecuteReader