Click here to Skip to main content
15,901,368 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi everyone...

Firstly I have successfully created an asp page that can connect, and add records to a database. Now I want to take it to the next level...I want to create a windows forms application that connects to a sql (or access Database).

I was able to add the the connection to the database through the server explorer, and when I click test connection it succeeds.

My Problem is when I try to add the Data Source, I start the Data Source connection wizard click next twice, then when asked if I want to save the connection string to the application configuration file I get an unexpected error. I just can not get it to complete this step

I am using Visual Studio 2008 (sp1), sql server 2008 r2.

Many Thanks in advance...
Posted

Firstly thanks for the very quick replies. Will vote accordingly.

I figured out what the answer is...

In short, I am running a 64 bit operating system (left out of op), and the there is no 64-bit version jet.oledb driver. Simply change the platform target to x86 and bobs your uncle...

The road to discovery, instead of using the Data Source Configuration Wizard I decided to drag a few controls ( DataGridView, BindingSource, textBox, and Button ) onto the form and do it with code. Eventually I got the error:

"Microsoft.Jet.OLEDB.4.0" has not been registered."

After I changed the platform target to x86 it worked right away.

The test code I used:

Get your query string, and your connection string then ...

C#
//create an OleDbDataAdapter to execute the query
            OleDbDataAdapter dAdapter = new OleDbDataAdapter(query, connString);

            //create a command builder
            OleDbCommandBuilder cBuilder = new OleDbCommandBuilder(dAdapter);

            //create a DataTable to hold the query results
            DataTable dTable = new DataTable();

            //fill the DataTable
            dAdapter.Fill(dTable);

            //set the BindingSource DataSource
         //   BindingSource1.DataSource = dTable; was unable to use the bindingSource control therefore...

            //BindingSource to sync DataTable and DataGridView
            BindingSource bSource = new BindingSource();

            //set the BindingSource DataSource
            bSource.DataSource = dTable;

            //set the DataGridView DataSource
            dataGridView1.DataSource = BindingSource1;


The reason I give this bit of code is because I was still unable to successfully complete the Wizard, even after changing the platform to x86.
 
Share this answer
 
v2
 
Share this answer
 
if(you'r pc.OS == OS.Win7)
{
you should Run as Administrator your vs2008
}

Aside .. you can use berjis component.. it's so easy to use...

Code Generator And Framework[^]

plz vote me for more help
 
Share this answer
 
v2
Comments
Bala Selvanayagam 7-Apr-12 8:27am    
The link you have provided is not working (not approved yet...).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900