Results 1 to 3 of 3

Thread: Exception generated. HELP!!!!

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2002
    Posts
    18

    Angry 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()
    ----------------------------------------------------------------------------------

  2. #2
    Fanatic Member Patoooey's Avatar
    Join Date
    Aug 2001
    Location
    New Jersey, USA
    Posts
    774

    Re: Exception generated. HELP!!!!

    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

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2002
    Posts
    18

    Finally figured it out

    The exception being generated was an 'Could not update query' kind of thing. I had to go to the folder where the database was residing, go to the security permissions and give the write permission to everyone.

    MS has already documented this on their website.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width