1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Error in connection database

Discussion in 'C#' started by lieweffect, Jun 4, 2006.

  1. lieweffect

    lieweffect New Member

    Once I run the program it give me this error:
    An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll

    Here is the code:
    OleDbConnection Conn=new OleDbConnection(ConnString);
    Conn.Open();
    OleDbDataReader dr;
    OleDbCommand dbcom=new OleDbCommand();
    DataSet ds=new DataSet();
    OleDbDataAdapter da=new OleDbDataAdapter();
    da.SelectCommand=new OleDbCommand(Sqlstring,Conn);
    da.Fill(ds);
    dbcom.Connection=(Conn);
    dbcom.CommandText=Sqlstring;
    dr=dbcom.ExecuteReader();

    it say the dbcom is undefined value.
    How to fix it
    Help!Thank Q
     
  2. shabbir

    shabbir Administrator Staff Member

    It looks like you have an error in the SQL query probably.
     
  3. lieweffect

    lieweffect New Member

    So,what should I do and how to fix it.
    Thank Q
     
    Last edited: Jun 5, 2006
  4. shabbir

    shabbir Administrator Staff Member

    By correcting the errors in the query.
     
  5. lieweffect

    lieweffect New Member

    May I know how to correct it please?
     
  6. shabbir

    shabbir Administrator Staff Member

    If you can share the query we can definitely look into it.
     
  7. lieweffect

    lieweffect New Member

    Here is the whole program code
     
  8. shabbir

    shabbir Administrator Staff Member

    Please dont attach the complete projects as its very difficult to find where the error is and where the query is. I have removed the attached project.

    Please read [thread=168]Before you make a query[/thread].
     
  9. lieweffect

    lieweffect New Member

    Sorry, because I don't know how to find the query as you know I'm the beginner of programming.If I did something please correct me!
     

    Attached Files:

    • db.doc
      File size:
      1.5 KB
      Views:
      7
  10. shabbir

    shabbir Administrator Staff Member

    Whats the value of Sqlstring when its giving the exception.
     
  11. lieweffect

    lieweffect New Member

    it say the dbcom is undefined value.
     
  12. shabbir

    shabbir Administrator Staff Member

    Sqlstring is passed as variable to FillListBox function and so the value of Sqlstring can be determined before hand only and you dont need to be going through the OleDb code.
     
  13. lieweffect

    lieweffect New Member

    If I don't going through the OleDb code. The data will not list at the list box there.
     
  14. shabbir

    shabbir Administrator Staff Member

    But to get that all you need is call that function with a string and the error is in the string.
     
  15. coderzone

    coderzone Super Moderator

    lieweffect probably you need to concentrate on basics first and get the grasp and then go for database programming in C#.
     
  16. lieweffect

    lieweffect New Member

    Thank Q for your advise coderzone
    Actually the original program is in vb code.
    It can run properly.
    After I convert it into c# follow the c# syntax it cannot run.
    So,may I know which is the mistake from the code
    Thank Q
     
  17. shabbir

    shabbir Administrator Staff Member

    The error is in creation of the sql string.
     
  18. lieweffect

    lieweffect New Member

    Thank Q
    I try to create again
     

Share This Page