Solved

Problem with OdbcDataAdapter and OdbcCommandBuilder

Posted on 2006-11-11
4
391 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

706 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now