Solved

Problem with OdbcDataAdapter and OdbcCommandBuilder

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

Independent Software Vendors: 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

Suggested Solutions

Title # Comments Views Activity
abstract class C# 1 44
Need help with another query 10 50
Pdf not loading 2 38
UWP: Create an Image/Bitmap, Draw another image on it an save. 1 39
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

738 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