Forum Post: ODBCCommandBuilder creating incomplete commands

  • Thread starter Thread starter bgourdie
  • Start date Start date
Status
Not open for further replies.
B

bgourdie

Guest
I'm trying to make a bare-bones CRUD app in C# with a DataGridView, DataTable, and DataAdapter. I can connect to the Progress database just fine but the ODBCCommandBuilder is creating SQL with only the number of indexes and the last index repeated across all of them. For example, updating a table with 4 indexes (and 13 or so columns) returns something like "UPDATE pub.Grade_Map SET mill = ?, mill = ?, mill = ?, mill = ? WHERE ((mill = ?) AND (mill = ?) AND (mill = ?) AND (mill = ?))". Likewise, for insert: "INSERT INTO pub.Grade_Map (mill, mill, mill, mill) VALUES (?, ?, ?, ?)". These commands "work" if there's a change in the index value, in which case it updates/inserts with the index value(s). Everything else is blank or remains untouched. Yeah, sure, I can build the insert, delete, and update statements myself, but then what am I getting out of using .NET? My code is about the minimum I'd expect to get this done, as I've created a SQL Server equivalent that works and simply changed the SQL classes to ODBC and altered the connection string. Using Progress 10.2B. ---------------------------------------------------- Code Start using System; using System.Data; using System.Data.Odbc; using System.Windows.Forms; namespace BareBonesODBCTableMaintenance { public partial class ODBCForm : Form { private const string connectionString = "Dsn=test;uid=BGOURDIE;host=main;port=2557;db=test102b"; private const string selectQuery = "select * from pub.Grade_Map"; private OdbcConnection con = new OdbcConnection(connectionString); private DataTable dt = new DataTable(); private static OdbcDataAdapter adapter = new OdbcDataAdapter(selectQuery, connectionString); private static OdbcCommandBuilder builder = new OdbcCommandBuilder(adapter); public ODBCForm() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { adapter.Fill(dt); dataGridView1.DataSource = dt; } private void commitToolStripMenuItem_Click(object sender, EventArgs e) { MessageBox.Show(builder.GetInsertCommand().CommandText); adapter.Update(dt); } } } -------------------------------------------------------- Code End

Continue reading...
 
Status
Not open for further replies.
Back
Top