CommandBuilder generates inproper SQL Statements

  • Thread starter Thread starter Thorsten Tarrach
  • Start date Start date
T

Thorsten Tarrach

Hallo,
The SQL Statements the CommandBuilder creates never work. (Wrong INSERT INTO
....)

To test this I created a new Access DB and a new application.
I used the wizzard in the IDE and here is the result:

---------
'OleDbSelectCommand1
'
Me.OleDbSelectCommand1.CommandText = "SELECT ID1, Tabelle1, Tabelle2 FROM
Tab1"
Me.OleDbSelectCommand1.Connection = Me.OleDbConnection1
'
'OleDbInsertCommand1
'
Me.OleDbInsertCommand1.CommandText = "INSERT INTO Tab1(Tabelle1, Tabelle2)
VALUES (?, ?)"
Me.OleDbInsertCommand1.Connection = Me.OleDbConnection1
Me.OleDbInsertCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Tabelle1",
System.Data.OleDb.OleDbType.VarChar, 50, "Tabelle1"))
Me.OleDbInsertCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Tabelle2",
System.Data.OleDb.OleDbType.VarChar, 50, "Tabelle2"))
 
I gave up using the CommandBuilder to generate Insert/Update/Delete command.
It just does not work and I think Microsoft said the same indirectly in
their documentation.

My suggestion would be--create your own Command where you have 100 percent
control.

Prodip Saha
 
Prodip Saha said:
I gave up using the CommandBuilder to generate Insert/Update/Delete command.
It just does not work and I think Microsoft said the same indirectly in
their documentation.

My suggestion would be--create your own Command where you have 100 percent
control.

It works fine if I change the CommandType to TableDirect.

Making all the commands myself is to much work in my opinion. The
CommandBuilder should be able to handle simple SELECT * FROM statements.
 
Back
Top