Exception generated. HELP!!!!
Hi,
I have the following code which generates an exception. I am not sure what I am doing wrong.
------------------------------------------------------------------------------------
Dim InsertCmd1 As String = "INSERT INTO SITELIST (SITEID, SITENAME) VALUES (@SITEID, @SITENAME)"
MyCommand1 = New OleDBCommand(InsertCmd1, MyConnection)
MyCommand1.Parameters.Add(New OleDBParameter("@SITEID", OleDBType.VarChar, len("@SITEID")))
MyCommand1.Parameters("@SITEID").Value = txtSiteID.Value
MyCommand1.Parameters.Add(New OleDBParameter("@SITENAME", OleDBType.VarChar, len(txtSiteName.Value)))
MyCommand1.Parameters("@SITENAME").Value = txtSiteName.Value
MyCommand1.Connection.Open()
'Try
MyCommand1.ExecuteNonQuery()
'Catch Exc As OleDBException
' Message.InnerHtml = "ERROR: Could not add record. Check to ensure that both the Site ID and Site Name are unique."
' Message.Style("color") = "red"
'End Try
MyCommand1.Connection.Close()
----------------------------------------------------------------------------------
Re: Exception generated. HELP!!!!
Quote:
Originally posted by kprashan
Hi,
I have the following code which generates an exception. I am not sure what I am doing wrong.
It would help if you posted the error message.
John