473,406 Members | 2,369 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Simple db-problem

Hello

Anyone know why i get:

Exception Details: System.ArgumentException: Format of the initialization
string does not conform to specification starting at index 0.

Line 14: OleDbConnection conn = new OleDbConnection("ConnectionString");
Web.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="ConnectionString" value="Data Source=127.0.0.1,1433;Network
Library=DBMSSOCN;Initial Catalog=northwind;User ID=sa;Password="/>
</appSettings>
<system.web>
</system.web>
</configuration>
code:

using System;

using System.Data;

using System.Data.OleDb;

namespace dbtest

{

/// <summary>

/// Summary description for WebForm1.

/// </summary>

public class WebForm1 : System.Web.UI.Page

{

private void Page_Load(object sender, System.EventArgs e)

{

OleDbConnection conn = new OleDbConnection("ConnectionString");

OleDbCommand cmd = new OleDbCommand("SalesByCategory",conn);

cmd.CommandType = CommandType.StoredProcedure;

// do stuff

conn.Close();

// Put user code to initialize the page here

}

#region Web Form Designer generated code

override protected void OnInit(EventArgs e)

{

//

// CODEGEN: This call is required by the ASP.NET Web Form Designer.

//

InitializeComponent();

base.OnInit(e);

}
/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.Load += new System.EventHandler(this.Page_Load);

}

#endregion

}

}
Nov 18 '05 #1
4 1301
Lasse Edsvik wrote:
Hello

Anyone know why i get:

Exception Details: System.ArgumentException: Format of the
initialization string does not conform to specification starting at
index 0.

Line 14: OleDbConnection conn = new
OleDbConnection("ConnectionString");

You supply the string "ConnectionString" as connection string, and that is
*not* the correct format :-)
You want this:
OleDbConnection conn = new OleDbConnection(
ConfigurationSettings.AppSettings["ConnectionString"]);

By the way, you seem to connect to SqlServer. There are specific classes
tuned for SqlServer! (SqlConnection, SqlCommand etc)

Hans Kesting


Web.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="ConnectionString" value="Data
Source=127.0.0.1,1433;Network Library=DBMSSOCN;Initial
Catalog=northwind;User ID=sa;Password="/> </appSettings>
<system.web>
</system.web>
</configuration>
code:

using System;

using System.Data;

using System.Data.OleDb;

namespace dbtest

{

/// <summary>

/// Summary description for WebForm1.

/// </summary>

public class WebForm1 : System.Web.UI.Page

{

private void Page_Load(object sender, System.EventArgs e)

{

OleDbConnection conn = new OleDbConnection("ConnectionString");

OleDbCommand cmd = new OleDbCommand("SalesByCategory",conn);

cmd.CommandType = CommandType.StoredProcedure;

// do stuff

conn.Close();

// Put user code to initialize the page here

}

#region Web Form Designer generated code

override protected void OnInit(EventArgs e)

{

//

// CODEGEN: This call is required by the ASP.NET Web Form Designer.

//

InitializeComponent();

base.OnInit(e);

}
/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.Load += new System.EventHandler(this.Page_Load);

}

#endregion

}

}

Nov 18 '05 #2
Hans,

Ok, i'll try with sqlclasses, but i still get same error
and when i type ConfigurationSettings i dont get any methods or properties.
whats missing?

"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:uX**************@TK2MSFTNGP10.phx.gbl...
Lasse Edsvik wrote:
Hello

Anyone know why i get:

Exception Details: System.ArgumentException: Format of the
initialization string does not conform to specification starting at
index 0.

Line 14: OleDbConnection conn = new
OleDbConnection("ConnectionString");


You supply the string "ConnectionString" as connection string, and that is
*not* the correct format :-)
You want this:
OleDbConnection conn = new OleDbConnection(
ConfigurationSettings.AppSettings["ConnectionString"]);

By the way, you seem to connect to SqlServer. There are specific classes
tuned for SqlServer! (SqlConnection, SqlCommand etc)

Hans Kesting


Web.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="ConnectionString" value="Data
Source=127.0.0.1,1433;Network Library=DBMSSOCN;Initial
Catalog=northwind;User ID=sa;Password="/> </appSettings>
<system.web>
</system.web>
</configuration>
code:

using System;

using System.Data;

using System.Data.OleDb;

namespace dbtest

{

/// <summary>

/// Summary description for WebForm1.

/// </summary>

public class WebForm1 : System.Web.UI.Page

{

private void Page_Load(object sender, System.EventArgs e)

{

OleDbConnection conn = new OleDbConnection("ConnectionString");

OleDbCommand cmd = new OleDbCommand("SalesByCategory",conn);

cmd.CommandType = CommandType.StoredProcedure;

// do stuff

conn.Close();

// Put user code to initialize the page here

}

#region Web Form Designer generated code

override protected void OnInit(EventArgs e)

{

//

// CODEGEN: This call is required by the ASP.NET Web Form Designer.

//

InitializeComponent();

base.OnInit(e);

}
/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.Load += new System.EventHandler(this.Page_Load);

}

#endregion

}

}


Nov 18 '05 #3
Lasse Edsvik wrote:
Hans,

Ok, i'll try with sqlclasses, but i still get same error
and when i type ConfigurationSettings i dont get any methods or
properties. whats missing?


add this to the top of the class file:
using System.Configuration;

then it should work

Hans Kesting

"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:uX**************@TK2MSFTNGP10.phx.gbl...
Lasse Edsvik wrote:
Hello

Anyone know why i get:

Exception Details: System.ArgumentException: Format of the
initialization string does not conform to specification starting at
index 0.

Line 14: OleDbConnection conn = new
OleDbConnection("ConnectionString");


You supply the string "ConnectionString" as connection string, and
that is *not* the correct format :-)
You want this:
OleDbConnection conn = new OleDbConnection(
ConfigurationSettings.AppSettings["ConnectionString"]);

By the way, you seem to connect to SqlServer. There are specific
classes tuned for SqlServer! (SqlConnection, SqlCommand etc)

Hans Kesting

Nov 18 '05 #4
Hans Kesting wrote:
Lasse Edsvik wrote:
Hans,

Ok, i'll try with sqlclasses, but i still get same error
and when i type ConfigurationSettings i dont get any methods or
properties. whats missing?


add this to the top of the class file:
using System.Configuration;

then it should work

Hans Kesting


Just an additional note: when you use the sql-specific classes, you need
to change the connection string! Look up the SqlConnection.ConnectionString
property in MSDN: (watch out for wrap)
http://msdn.microsoft.com/library/de...tringtopic.asp

Hans Kesting
Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Joe | last post by:
I am trying to create a simple connection to a Access DB and receive the following OleDbException error System.Data.OleDb.OleDbException: Unspecified error at...
3
by: suzy | last post by:
Hello, I am trying to write a generic tool that accesses a SQL server and reads/updates/deletes/creates records. I want to reference this tool from my asp.net pages to talk to my db. by the...
9
by: Pete | last post by:
Does anyone have a simple html vbscript or other type of snippet they can share that appends a record to a access database via ADO or DAO? I would like to allow users that don't have Microsoft...
5
by: Lisa | last post by:
Hello, I am new to using recordsets, and i am completly stuck with this one. I am trying to use a multi select list box to write records to a table. Something in my code is causing the same...
1
by: Anonymous via the Cypherpunks Tonga Remailer | last post by:
Hi, I'm building a simple Object Oriented CMS using PHP5 and the new object model (new to both). I'm looking for some design advice on how best to integrate the database class - which creates...
1
by: Neal Middlemore | last post by:
Hi, I want to be able to add some simple security to one of my pages, basically my page allows users to submit a text field which gets parsed into MySQL db and displayed on other pages. At the...
6
by: Jim M | last post by:
I've been distributing a fairly mature, very specific MS Access application to end users in small offices of colleges for several years now. This is a part-time venture and low volume operation-...
3
by: larry | last post by:
Ok I am re-coding our apps in PHP and am looking for ways to make parts easily updateable, One of the challenges in my field (non-rpofit) are various lookup tables (for incomes etc). An example...
0
by: coosa | last post by:
Dear all; My code is is a bit long but is modular at least. I'm attempting to implement the depth first search for an application that is supposed to: 1- Fetch based on an ID from the database a...
1
by: Murdz | last post by:
Hello all, The HDD that holds the logs for one of our DB servers has run out of space (More has been ordered). Part of the reason for this is the log files have gotten rather large, as such the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.