Solved

Problem with OdbcDataAdapter and OdbcCommandBuilder

Posted on 2006-11-11
4
399 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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…

756 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