M
Matthew Louden
I just tried to create a simple ASP.NET application to add record to the SQL
Server database. However, it has run time error on Line 88:
objCommand.ExecuteNonQuery()
Any ideas?? Please help!! Thanks!!
Sub AddNewRecord()
Dim objConnection As SqlConnection
Dim strConnection As String = "Data Source=20.11.12.91;Network
Library=DBMSSOCN;Initial Catalog=testtable;User ID=sa;Password=iw;"
objConnection = New SqlConnection(strConnection)
Dim objCommand As SqlCommand
Dim strSQLQuery As String
strSQLQuery = "INSERT INTO Test " _
& "(FirstName, LastName, SerialNumber) " _
& "VALUES (@TextValue, @TextValue, @TextValue)"
objCommand = New SqlCommand(strSQLQuery, objConnection)
objCommand.Parameters.Add(New SqlParameter("@TextValue", SqlDbType.Char,
255))
objCommand.Parameters.Add(New SqlParameter("@TextValue", SqlDbType.Char,
255))
objCommand.Parameters.Add(New SqlParameter("@TextValue", SqlDbType.Char,
255))
objCommand.Parameters("@TextValue").Value = CStr(TextBox1.Text)
objCommand.Parameters("@TextValue").Value = CStr(TextBox2.Text)
objCommand.Parameters("@TextValue").Value = CStr(TextBox4.Text)
objConnection.Open()
objCommand.ExecuteNonQuery()
objConnection.Close()
End Sub
Runtime error:
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: ?? ??
'@TextValue'?(?) ?? ???????. ?? ??? ?? ?? ?? ?? ?? ???? ??? ???? ???.
Source Error:
Line 86: ' Open the connection, execute the command, and close the
connection.
Line 87: objConnection.Open()
Line 88: objCommand.ExecuteNonQuery()
Line 89: objConnection.Close()
Line 90:
Server database. However, it has run time error on Line 88:
objCommand.ExecuteNonQuery()
Any ideas?? Please help!! Thanks!!
Sub AddNewRecord()
Dim objConnection As SqlConnection
Dim strConnection As String = "Data Source=20.11.12.91;Network
Library=DBMSSOCN;Initial Catalog=testtable;User ID=sa;Password=iw;"
objConnection = New SqlConnection(strConnection)
Dim objCommand As SqlCommand
Dim strSQLQuery As String
strSQLQuery = "INSERT INTO Test " _
& "(FirstName, LastName, SerialNumber) " _
& "VALUES (@TextValue, @TextValue, @TextValue)"
objCommand = New SqlCommand(strSQLQuery, objConnection)
objCommand.Parameters.Add(New SqlParameter("@TextValue", SqlDbType.Char,
255))
objCommand.Parameters.Add(New SqlParameter("@TextValue", SqlDbType.Char,
255))
objCommand.Parameters.Add(New SqlParameter("@TextValue", SqlDbType.Char,
255))
objCommand.Parameters("@TextValue").Value = CStr(TextBox1.Text)
objCommand.Parameters("@TextValue").Value = CStr(TextBox2.Text)
objCommand.Parameters("@TextValue").Value = CStr(TextBox4.Text)
objConnection.Open()
objCommand.ExecuteNonQuery()
objConnection.Close()
End Sub
Runtime error:
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: ?? ??
'@TextValue'?(?) ?? ???????. ?? ??? ?? ?? ?? ?? ?? ???? ??? ???? ???.
Source Error:
Line 86: ' Open the connection, execute the command, and close the
connection.
Line 87: objConnection.Open()
Line 88: objCommand.ExecuteNonQuery()
Line 89: objConnection.Close()
Line 90: