when writing to DB error : Must declare the variable '@MID'
hello,
I was wondering if anybody can help me, When trying to write to my table, i am given the exception : Must declare the variable'@MID'
The other functions i have that do much the same thing work fine, so im not sure whats the cause? Im new to programming and any advice would be greatly appreciated.
Thanks a lot!!
Here is the code:
PublicFunction WriteSerialToDB(ByVal serialAsString,ByVal vMIDAsString,ByVal compIDAsString)AsBoolean
Dim
connStringAsString ="Data Source=Cayenne;Initial Catalog=""PCOPEN DATA"";Persist Security Info=True;User ID=*********;Password=********"Dim conInsertAs SqlConnectionDim strAddAsStringDim newCmdInsertAs SqlCommandDim MIDAsString = vMIDDim dte2AsString = DateTime.NowconInsert =
New SqlConnection(connString)strAdd ="INSERT tblOEM_ProductPurchase( ModelID, DateOrdered, SerialNumber, ProductRegistered ) Values ( @ModelID, @DateOrdered, @SerialNumber, @ProductRegistered)"
newCmdInsert =New SqlCommand(strAdd, conInsert)
cmdInsertParameters.AddWithValue("@ModelID", MID)
cmdInsert.Parameters.AddWithValue("@DateOrdered", dte2)
cmdInsert.Parameters.AddWithValues("@SerialNumber", serial)
cmdInsert.Parameters.AddWithValues("@ProductRegistered", "0")
TryconInsert.Open()
newCmdInsert.ExecuteNonQuery()
conInsert.Close()
Catch exAs Exception
ReturnFalse
EndTry
ReturnTrue
End Function

