If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Command text was not set for the command object.

Hello
I worked with this program couple of weeks ago and it worked properly but now I don't know why i get this error message when i try to insert new record. However it inserts and adds new record to the table it stops running and displays an error message"Command text was not set for the command object."
the arrow points to line started by >>>dataAdapter.Fill(studentTable)
this is not the completed code and in access database all field types are text.
any suggestion would be appreciated.

Thanks

global variables

Code:

Dim dataAdapter As OleDb.OleDbDataAdapter
Dim studentTable As New DataTable
Dim moduleTable As New DataTable
Dim optionTable As New DataTable
Dim searchTable As New DataTable
Dim markTable As New DataTable
Dim resultTable As New DataTable
Dim sqlStr As String
Dim connStr As String
Dim recordCount As Integer

Re: Command text was not set for the command object.

I have this line but I still got this error message!!!
Oh I don't know why but the error message differ from the last one I did not make any changes,error is "data type mismatch in criteria expression" and points to line dataAdapter.InsertCommand.ExecuteNonQuery()
any ideas???

Re: Command text was not set for the command object.

Thanks jroger
but I have a problem and that is the program works on saturdays and doesn't work on sundays. you know what I mean sometimes work properly even with the last code but sometime shows that error message and now it works but does not delete it it says deletion successful but doesn't reload the table. and I don't know what is the relation between insert and delete they both have the same problem.
any suggestions?

Re: Command text was not set for the command object.

here is the code for form1, I mean main form, in 2 posts.I have different form for some action and they work properly. at the moment the problem is insert and delete.they borh work but for insert it display the run time error"Command text was not set for the command object." and for deelete it does say deletion successful but doesn't reload the table.

Re: Command text was not set for the command object.

If I were you I would definitely have one dataadapter per datatable, and I would define them all to start with (including parameters) then when you want the data you can convcentrate on calling the required method of the relevant dataadapter.