[thelist] Oops! Parameters in ASP.Net

Ken Moore psm2713 at hotmail.com
Tue Oct 30 11:15:38 CDT 2007



Hi all,
 
I have a problem with the following code. It works if I hard code the numbers 3 and 3 but not if I use params. I get the following error:
Exception Details: System.Data.SqlClient.SqlException: The parameterized query '(@MainID int, at Num1 int)INSERT into RecordsDaily ( RecordsID_rec,' expects the parameter '@MainID', which was not supplied.
I know that this is a common problem and there are about 10,000 of you who can answer it.
 
TIA,
Ken
 
Dim Num1 As Integer
Num1 = 3
Dim MainID As Integer
MainID = 3

' Initialize connection
conn = New SqlConnection("Server=localhost\SqlExpress;" & _
"Database=ROADS;Integrated Security=True")
conn.Open()

' Create, execute command
comm = New SqlCommand("INSERT into RecordsDaily ( RecordsID_rec,BookingDay_rec) values ( @MainID, @Num1)", conn)
comm.Parameters.Add("@MainID", Data.SqlDbType.Int)
comm.Parameters.Add("@Num1", Data.SqlDbType.Int)
comm.ExecuteNonQuery()
_________________________________________________________________
Help yourself to FREE treats served up daily at the Messenger Café. Stop by today.
http://www.cafemessenger.com/info/info_sweetstuff2.html?ocid=TXT_TAGLM_OctWLtagline


More information about the thelist mailing list