Results 1 to 5 of 5

Thread: db error

  1. #1

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075

    db error

    I'm getting this error when I hit this line objCommand.ExecuteNonQuery()

    An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll



    Code:
     Dim sqlCmd As String = "insert into DBATEST.PCMS_Billing_Period (begin_billing_date,end_billing_date,credit_card_no,employee_work_unit,status_ind) "
            sqlCmd = sqlCmd & "values (?,?,?,?,?)"
            Dim objCommand As New OleDbCommand(sqlCmd, objConnection)
            objCommand.Parameters.Add("@begin_billing_date", System.Data.OleDb.OleDbType.Date).Value = dp1.Value
            objCommand.Parameters.Add("@end_billing_date", System.Data.OleDb.OleDbType.Date).Value = dp2.Value
            objCommand.Parameters.Add("@credit_card_no", System.Data.OleDb.OleDbType.Char, 16).Value = txtCreditNo.Text
            objCommand.Parameters.Add("@employee_work_unit", System.Data.OleDb.OleDbType.Char, 4).Value = txtWorkUnit.Text
            objCommand.Parameters.Add("@status_ind", System.Data.OleDb.OleDbType.Char, 1).Value = Post_to_Int
            objConnection.Open()
            objCommand.ExecuteNonQuery()
            objConnection.Close()

  2. #2
    Fanatic Member Mr.No's Avatar
    Join Date
    Sep 2002
    Location
    Mauritius
    Posts
    651
    Just wondering....

    Shouldn't the ?,?,?,? in command string be replaced with @end_billing_date, @credit_card_no, @employee_work_unit, @status_ind
    Using VB.NET 2003/.NET 1.1/C# 2.0
    http://del.icio.us/rajoo
    Blow your mind, smoke gunpowder
    Ashes to ashes, dust to dust
    If God won't have you, the devil will. - Author unknown
    Don't follow me, I'm lost too ...

  3. #3

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    I've been using that code on other apps and it has been working fine...till now!

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    try using your table name like this
    VB Code:
    1. [DBATEST.PCMS_Billing_Period]
    usually , this error caused by connection strings , SQL string(misspelled table name ..)

  5. #5

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    thanks guys...I put the DB connection in a Try, Catch block and got a more detailed error message...it was an inccorect table name..

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