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
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].
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!
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.
lieweffect probably you need to concentrate on basics first and get the grasp and then go for database programming in C#.
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