sql connectivity using stored procedure in asp.net
Hi! this is kk. I have been trying to connect to sql db server2000 using asp.net thru stored procedure. but while retreiving the result
parameter from the stored procedure, its given the error:
Syntax error converting the varchar value 'new' to a column of data type int.
Can anybody help me please to solve this problem i've written the follg code. i declared all the vars before page load, and used a fun for connection
Function CONCODE()
CON = New SqlConnection("Persist Security Info=False;User ID=sa;Initial Catalog=phones4u;Data Source=ANSHULBA")
Return CON
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
QUERY = "pro_to_cheq_logindetails"
CMD = New SqlCommand(QUERY, CONCODE())
CON.Open()
CMD.CommandType = CommandType.StoredProcedure
CMD.Parameters.Add("@userid", LTrim(RTrim(TextBox1.Text)))
CMD.Parameters.Add("@pwd", LTrim(RTrim(TextBox2.Text)))
Dim p1 As SqlParameter
p1 = CMD.Parameters.Add("@res", SqlDbType.VarChar)
p1.Size = 3
p1.Direction = ParameterDirection.Output
p1.DbType = DbType.String
CMD.ExecuteNonQuery()
Dim STR As String
STR = CMD.Parameters("@res").Value
CON.Close()
Label3.Text = STR
Catch ex As Exception
Label3.Text = ex.Message
End Try
End Sub
|