Wrox Programmer Forums
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 12th, 2004, 02:15 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 146
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to aadz5
Default ADO.NET

Hi guys,

I am trying to populate a datagrid using a data adapter. When ever I execute the file this is the error I get: -

An unhandled exception of type 'System.ArgumentException' occurred in system.data.dll

Additional information: Format of the initialization string does not conform to specification starting at index 0.

This is my Code: -

private void button1_Click(object sender, System.EventArgs e)
        {
            string source = "Provider = Microsoft.Jet.OleDb.4.0; data source=D:\\House or Home Site\\House.mdb;";
            string Select = "SELECT * FROM Houses";
            OleDbConnection objConnection = new OleDbConnection(Select);
            OleDbCommand objCommand = new OleDbCommand(Select, objConnection);
            OleDbDataAdapter objAdapter = new OleDbDataAdapter(Select, objConnection);
            DataSet objDataSet = new DataSet();
            objAdapter.Fill(objDataSet, "Houses");
            //OleDbDataReader objDataReader = null;
            //objConnection.Open();
            //objCommand.ExecuteNonQuery();
            //dataGrid1.DataSource = objDataReader;
            dataGrid1.SetDataBinding(objDataSet, "Houses");
        }

Any ideas

Adz - The World is not enough
__________________
Adz - Learning The J2EE Ways.
 
Old May 4th, 2004, 07:05 AM
Authorized User
 
Join Date: Jun 2003
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default

well... one thing on your code I can see is incorrect,
OleDbConnection objConnection = new OleDbConnection(Select);
should be: OleDbConnection objConnection = new OleDbConnection(source);
try this first, the rest of the code seems to be OK.

Kas.








Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between ADO and ADO.NET rakeshclose2u ADO.NET 2 April 23rd, 2007 03:57 AM
ADO AND ADO.NET royalsurej ADO.NET 1 November 8th, 2004 08:28 AM
How can connect VB.Net with ADO.Net? arvind_pathak VS.NET 2002/2003 1 November 6th, 2003 09:22 AM
ADO.NET with ASP.NET stu9820 ADO.NET 5 September 2nd, 2003 11:47 AM
MSDE and SQL CE (using VB.NET and ADO.NET) LEGS ADO.NET 0 July 12th, 2003 11:27 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.