thepooh
July 14th, 2003, 10:37 PM
I created a stored procedure during the development of the vb.net windows application.
When I run the program, there's no error. But when I check in sqlserver7.0, the data is not inserted. I've already made sure that in the SQL Enterprise Manager, Permission, the Exec box is checked. Below is the code which I wrote:
Dim CreditCard_ACFConn As New SqlConnection("workstation id=""MyServer"";packet size=4096;user id=sa;data source=""MyServer"";persist security info=False;initial catalog=CreditCard_ACF")
Dim InsertCHCmd2 As New SqlCommand("spInsertCardHolderNonAgent", CreditCard_ACFConn)
InsertCHCmd2.CommandType = CommandType.StoredProcedure
Dim parmCHName2 As New SqlParameter("@CardHolderName", SqlDbType.VarChar, 255)
parmCHName2.Value = txtCHName.Text
InsertCHCmd2.Parameters.Add(parmCHName2)
CreditCard_ACFConn.Open()
InsertCHCmd2.ExecuteNonQuery()
CreditCard_ACFConn.Close()
If I replace the Stored Procedure name with SQL command, the same code can run perfectly!
Dim CreditCard_ACFConn As New SqlConnection("workstation id=""MyServer"";packet size=4096;user id=sa;data source=""MyServer"";persist security info=False;initial catalog=CreditCard_ACF")
Dim InsertCHCmd2 As New SqlCommand("Insert into CardHolder (CardHolderName) Values (@CardHolderName)", CreditCard_ACFConn)
InsertCHCmd2.CommandType = CommandType.Text
Dim parmCHName2 As SqlParameter = InsertCHCmd2.Parameters.Add("@CardHolderName", SqlDbType.VarChar, 255)
parmCHName2.Value = txtCHName.Text
CreditCard_ACFConn.Open()
InsertCHCmd2.ExecuteNonQuery()
CreditCard_ACFConn.Close()
Please help. thanks
When I run the program, there's no error. But when I check in sqlserver7.0, the data is not inserted. I've already made sure that in the SQL Enterprise Manager, Permission, the Exec box is checked. Below is the code which I wrote:
Dim CreditCard_ACFConn As New SqlConnection("workstation id=""MyServer"";packet size=4096;user id=sa;data source=""MyServer"";persist security info=False;initial catalog=CreditCard_ACF")
Dim InsertCHCmd2 As New SqlCommand("spInsertCardHolderNonAgent", CreditCard_ACFConn)
InsertCHCmd2.CommandType = CommandType.StoredProcedure
Dim parmCHName2 As New SqlParameter("@CardHolderName", SqlDbType.VarChar, 255)
parmCHName2.Value = txtCHName.Text
InsertCHCmd2.Parameters.Add(parmCHName2)
CreditCard_ACFConn.Open()
InsertCHCmd2.ExecuteNonQuery()
CreditCard_ACFConn.Close()
If I replace the Stored Procedure name with SQL command, the same code can run perfectly!
Dim CreditCard_ACFConn As New SqlConnection("workstation id=""MyServer"";packet size=4096;user id=sa;data source=""MyServer"";persist security info=False;initial catalog=CreditCard_ACF")
Dim InsertCHCmd2 As New SqlCommand("Insert into CardHolder (CardHolderName) Values (@CardHolderName)", CreditCard_ACFConn)
InsertCHCmd2.CommandType = CommandType.Text
Dim parmCHName2 As SqlParameter = InsertCHCmd2.Parameters.Add("@CardHolderName", SqlDbType.VarChar, 255)
parmCHName2.Value = txtCHName.Text
CreditCard_ACFConn.Open()
InsertCHCmd2.ExecuteNonQuery()
CreditCard_ACFConn.Close()
Please help. thanks