469,623 Members | 1,850 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,623 developers. It's quick & easy.

What's wrong with my connection string to the Access db?

I have a connection string like this, anyone know how can I fix it?

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<html>
<body>
<!-- #include file = "linkx.inc" -->
<script language="C#" runat="server">
protected void Page_Load(Object sender, EventArgs e)
{
string mysql;
OleDbConnection myConnection = new OleDbConnection();
myConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\\inetpub\\wwwroot\\break.mdb;";

mysql = "SELECT Date, Build, Count(*) as num FROM BVTbreak GROUP BY Date,
Build where status = 5 order by Build DESC;";
OleDbDataAdapter myCommand = OleDbDataAdapter(mysql, myConnection);

DataSet ds = new DataSet();
myCommand.Fill(ds, "Waive");

MyDataGrid.DataSource=ds.Tables["Waive"].DefaultView;
MyDataGrid.DataBind();
}
I got the compilation error:

Line 18: OleDbAdapter myCommand = OleDbAdapter(mysql, myConnection);


--

還我本色
Forever Bad.
Nov 18 '05 #1
5 3996
Hello, I do not know much about C or C# but i do know VB. Here is how it
would be done in vb and you can modify it to work in the language you are
using.

Page Load Event

Dim AConnectionString as string = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\inetpub\wwwroot\break.mdb;"

**** There is a better place for the database*******

Dim ADataset as New Dataset

Dim ADataAdapter as new oledb.DataAdapter("SELECT Date, Build, Count(*) as
num FROM BVTbreak GROUP BY Date, Build where status = 5 order by Build
DESC;", AConnectionString)

ADataAdapter.Fill(ADataset, "Waive")

MyDataGrid.DataSource=ADataset.Tables("Waive").Def aultView

MyDataGrid.DataBind()

**** You don't need a connection object but it is better to use a command
object and parameters for your querries.

Chuck

"Aries" <a> wrote in message news:Ma********************@speakeasy.net...
I have a connection string like this, anyone know how can I fix it?

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<html>
<body>
<!-- #include file = "linkx.inc" -->
<script language="C#" runat="server">
protected void Page_Load(Object sender, EventArgs e)
{
string mysql;
OleDbConnection myConnection = new OleDbConnection();
myConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\\inetpub\\wwwroot\\break.mdb;";

mysql = "SELECT Date, Build, Count(*) as num FROM BVTbreak GROUP BY Date,
Build where status = 5 order by Build DESC;";
OleDbDataAdapter myCommand = OleDbDataAdapter(mysql, myConnection);

DataSet ds = new DataSet();
myCommand.Fill(ds, "Waive");

MyDataGrid.DataSource=ds.Tables["Waive"].DefaultView;
MyDataGrid.DataBind();
}
I got the compilation error:

Line 18: OleDbAdapter myCommand = OleDbAdapter(mysql, myConnection);


--

還我本 Forever Bad.

Nov 18 '05 #2
What exactly is "the compilation error?"

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Aries" <a> wrote in message news:Ma********************@speakeasy.net...
I have a connection string like this, anyone know how can I fix it?

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<html>
<body>
<!-- #include file = "linkx.inc" -->
<script language="C#" runat="server">
protected void Page_Load(Object sender, EventArgs e)
{
string mysql;
OleDbConnection myConnection = new OleDbConnection();
myConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\\inetpub\\wwwroot\\break.mdb;";

mysql = "SELECT Date, Build, Count(*) as num FROM BVTbreak GROUP BY Date,
Build where status = 5 order by Build DESC;";
OleDbDataAdapter myCommand = OleDbDataAdapter(mysql, myConnection);

DataSet ds = new DataSet();
myCommand.Fill(ds, "Waive");

MyDataGrid.DataSource=ds.Tables["Waive"].DefaultView;
MyDataGrid.DataBind();
}
I got the compilation error:

Line 18: OleDbAdapter myCommand = OleDbAdapter(mysql, myConnection);


--

還我本色 Forever Bad.

Nov 18 '05 #3
Sorry that I forgot to put down. Here is the error message

Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: CS0246: The type or namespace name
'OleDbDataAdapter' could not be found (are you missing a using directive or
an assembly reference?)

--

還我本色
Forever Bad.
"Kevin Spencer" <ks******@takempis.com> wrote in message
news:Ot**************@TK2MSFTNGP11.phx.gbl...
What exactly is "the compilation error?"

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Aries" <a> wrote in message news:Ma********************@speakeasy.net...
I have a connection string like this, anyone know how can I fix it?

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<html>
<body>
<!-- #include file = "linkx.inc" -->
<script language="C#" runat="server">
protected void Page_Load(Object sender, EventArgs e)
{
string mysql;
OleDbConnection myConnection = new OleDbConnection();
myConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\\inetpub\\wwwroot\\break.mdb;";

mysql = "SELECT Date, Build, Count(*) as num FROM BVTbreak GROUP BY Date, Build where status = 5 order by Build DESC;";
OleDbDataAdapter myCommand = OleDbDataAdapter(mysql, myConnection);

DataSet ds = new DataSet();
myCommand.Fill(ds, "Waive");

MyDataGrid.DataSource=ds.Tables["Waive"].DefaultView;
MyDataGrid.DataBind();
}
I got the compilation error:

Line 18: OleDbAdapter myCommand = OleDbAdapter(mysql, myConnection);


--

還我本色
Forever

Bad.


Nov 18 '05 #4
Ah, thanks Aries! I should have spotted the problem before, but your reply
helped me to spot it this time. Your line of code reads:

OleDbDataAdapter myCommand = OleDbDataAdapter(mysql, myConnection);

It SHOULD read:

OleDbDataAdapter myCommand = new OleDbDataAdapter(mysql, myConnection);

You may not have known to use the new operator, as the C# documentation in
the .Net SDK lists the constructor method of a class as simply the class
name, while VB.Net's documentation specifically calls this function New.
However, every class constructor method must be called using the new
operator.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Aries" <a> wrote in message news:59********************@speakeasy.net...
Sorry that I forgot to put down. Here is the error message

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0246: The type or namespace name
'OleDbDataAdapter' could not be found (are you missing a using directive or an assembly reference?)

--

還我本色 Forever Bad. "Kevin Spencer" <ks******@takempis.com> wrote in message
news:Ot**************@TK2MSFTNGP11.phx.gbl...
What exactly is "the compilation error?"

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Aries" <a> wrote in message news:Ma********************@speakeasy.net...
I have a connection string like this, anyone know how can I fix it?

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<html>
<body>
<!-- #include file = "linkx.inc" -->
<script language="C#" runat="server">
protected void Page_Load(Object sender, EventArgs e)
{
string mysql;
OleDbConnection myConnection = new OleDbConnection();
myConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\inetpub\\wwwroot\\break.mdb;";

mysql = "SELECT Date, Build, Count(*) as num FROM BVTbreak GROUP BY Date, Build where status = 5 order by Build DESC;";
OleDbDataAdapter myCommand = OleDbDataAdapter(mysql, myConnection);

DataSet ds = new DataSet();
myCommand.Fill(ds, "Waive");

MyDataGrid.DataSource=ds.Tables["Waive"].DefaultView;
MyDataGrid.DataBind();
}
I got the compilation error:

Line 18: OleDbAdapter myCommand = OleDbAdapter(mysql, myConnection);


--

還我本色
Forever Bad.



Nov 18 '05 #5
It works. Thank you very much Kevin.

--

還我本色
Forever Bad.
"Kevin Spencer" <ks******@takempis.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Ah, thanks Aries! I should have spotted the problem before, but your reply
helped me to spot it this time. Your line of code reads:

OleDbDataAdapter myCommand = OleDbDataAdapter(mysql, myConnection);

It SHOULD read:

OleDbDataAdapter myCommand = new OleDbDataAdapter(mysql, myConnection);

You may not have known to use the new operator, as the C# documentation in
the .Net SDK lists the constructor method of a class as simply the class
name, while VB.Net's documentation specifically calls this function New.
However, every class constructor method must be called using the new
operator.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Aries" <a> wrote in message news:59********************@speakeasy.net...
Sorry that I forgot to put down. Here is the error message

Description: An error occurred during the compilation of a resource

required
to service this request. Please review the following specific error

details
and modify your source code appropriately.

Compiler Error Message: CS0246: The type or namespace name
'OleDbDataAdapter' could not be found (are you missing a using directive

or
an assembly reference?)

--

還我本色
Forever

Bad.
"Kevin Spencer" <ks******@takempis.com> wrote in message
news:Ot**************@TK2MSFTNGP11.phx.gbl...
What exactly is "the compilation error?"

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Aries" <a> wrote in message news:Ma********************@speakeasy.net... > I have a connection string like this, anyone know how can I fix it?
>
> <%@ Import Namespace="System.Data" %>
> <%@ Import Namespace="System.Data.OleDb" %>
> <html>
> <body>
> <!-- #include file = "linkx.inc" -->
> <script language="C#" runat="server">
>
>
> protected void Page_Load(Object sender, EventArgs e)
> {
> string mysql;
> OleDbConnection myConnection = new OleDbConnection();
> myConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data > Source=c:\\inetpub\\wwwroot\\break.mdb;";
>
> mysql = "SELECT Date, Build, Count(*) as num FROM BVTbreak GROUP BY

Date,
> Build where status = 5 order by Build DESC;";
> OleDbDataAdapter myCommand = OleDbDataAdapter(mysql, myConnection);
>
> DataSet ds = new DataSet();
> myCommand.Fill(ds, "Waive");
>
> MyDataGrid.DataSource=ds.Tables["Waive"].DefaultView;
> MyDataGrid.DataBind();
> }
>
>
> I got the compilation error:
>
> Line 18: OleDbAdapter myCommand = OleDbAdapter(mysql, myConnection);
>
>
>
>
> --
>
>
還我本色
> Forever Bad.
>
>



Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Charles shao | last post: by
2 posts views Thread by Benoit Martin | last post: by
10 posts views Thread by Daniel S幨en Secches | last post: by
1 post views Thread by Dean Slindee | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.