Solved

Problem with OdbcDataAdapter and OdbcCommandBuilder

Posted on 2006-11-11
4
398 Views
Last Modified: 2008-02-01
Hi,

I'm trying to use an OdbcCommandBuilder to build an Insert statement for a table.

      OdbcDataAdapter adapter = new OdbcDataAdapter(sqlSelect, connectionObject);
      OdbcCommandBuilder cmdBuilder = new OdbcCommandBuilder(adapter);
      OpenConnection();
      adapter.InsertCommand = cmdBuilder.GetInsertCommand();
      return adapter;

When I get to the "adapter.InsertCommand = " statement, I get the following error:

"ERROR - no error information available"

I've used this connection object elsewhere to read info from a table, so I know the connection object is ok.

Is there any way I can get more info on what's happening? Or can anyone suggest any possible solutions?

Many thanks
0
Comment
Question by:gamesmeister
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
so3 earned 500 total points
ID: 17924742
try this to see if it's working. Also make sure that table has a primary key(id column) for the update to work

           OdbcConnection connectionObject = new OdbcConnection();
            OdbcDataAdapter adapter = new OdbcDataAdapter(connectionObject);
            adapter.SelectCommand = new OdbcCommand(sqlSelect);
            OdbcCommandBuilder cmdBuilder = new OdbcCommandBuilder(adapter);
            connectionObject.Open();

            DataSet ds = new DataSet();
            adapter.Fill(ds, myTableName);
//this is to see if the update,delete,insert commands are correct
            txtUpdate.Text = cmdBuilder .GetUpdateCommand().CommandText
            txtDelete.Text = cmdBuilder .GetDeleteCommand().CommandText
            txtInsert.Text = cmdBuilder .GetInsertCommand().CommandText


            adapter.Update(ds, myTableName);
            connectionObject.Close();
            return adapter;

0
 
LVL 6

Expert Comment

by:so3
ID: 17924746
delete the first line in my previous comment and use your connectionObject

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question