Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Over the past few days I have been working on an application that iterates through dBase files and outputs the information in a listbox or datagrid. I seem to have gotten the connection string right as I don't get an error when I open the dbf file, but, whenever I add in the DataAdapter and DataSet I get an error. It might help to know that I am using VS .NET 2005 and I am trying to connect to the dBase files using ODBC. Below is the code I am using and an image of the error I get.

 

OdbcConnection conn = new OdbcConnection();
           conn.ConnectionString = ("Driver={Microsoft dBASE Driver (*.dbf)};DriverID=21;Dbq=I:\\MDT_1.4\\;");

           try
           {
               // Open Drawing Database
               conn.Open();

               // Query
               string jobData = "SELECT DWG_NAME, DWG_NUMBER FROM DRAWINGS.dbf";

               
               OdbcCommand cmd = new OdbcCommand();
               cmd.CommandText = (jobData);

               OdbcDataAdapter dbAdapter = new OdbcDataAdapter(jobData, conn);   //<---Error begins here (I think)

               DataSet dtSet = new DataSet();
               dbAdapter.Fill(dtSet);

               DataTable dbTable = dtSet.Tables[0];

               foreach (DataRow dbRow in dbTable.Rows)
               {
                   outputListBox.Items.Add(dbRow["DWG_NAME"].ToString());
               }

 

Thanks for your help

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...