[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Problem with OdbcDataAdapter and OdbcCommandBuilder

Posted on 2006-11-11
4
Medium Priority
?
415 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
2 Comments
 
LVL 6

Accepted Solution

by:
so3 earned 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

830 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