where are the wrong codes??? I can't find.

T

Tao Lei

Please:
I wrote these lines of codes of ASP.Net. But it goes wrong.
Why??? Who can help me?
Thank you very much!!!

<% @Page Language="C#"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Odbc" %>

<html>
<head>
<Script runat="server">
void page_Load(Object Source, EventArgs E)
{
string strSQL="select * from TEST";
string strconn="Provider=MSDASQL.1;Persist Security Info=false;Data
Source=TEST_ACCESS";

OdbcConnection conn = new OdbcConnection(strconn);
OdbcDataAdapter adp = new OdbcDataAdapter(strSQL, conn);

DataSet ds = new DataSet();
adp.Fill(ds, "TEST");
DG1.DataSource = ds.Tables["TEST"];
DG1.DataBind();
}
</Script>

</head>
<body>
<center>
<asp:datagrid id="DG1" runat="server" />
</center>


The exception information are here

System.Data.Odbc.OdbcException : ERROR [IM002] [Microsoft][ODBC Driver
Manager] Data source name not found and no default driver specified
 
W

William \(Bill\) Vaughn

If you want to access an ODBC data source, you can't use the OLE DB MSDASQL
provider (the Kagera bridge provider) as it's not supported by .NET.
Actually, you don't need a "Provider=" keyword in the connection string for
the Odbc provider.
I also suspect you'll need some sort of security setting in the connection
string (UID=xx;pwd=yy;) or SSPI security.

string strconn="Data Source=TEST_ACCESS;trusted_connection=True";

I would also include a Try/Catch block around the code to trap the
exceptions and return more meaningful messages.

hth


--
____________________________________
Bill Vaughn
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
T

Tao Lei

Hello William:
I have not set any password or userID.(They would be empty string)
I only set up a System DSN named TEST_ACCESS in ODBC, there is no homonymy
DSN in User DSN. I also find no .ldb file in my system.
Fllowing your opinion, I write these codes, however, the result is the
same as usual ,why ???
Thank you.

<% @Page Language="C#"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Odbc" %>

<html>
<head>
<Script runat="server">
void page_Load(Object Source, EventArgs E)
{
string strSQL="select * from TEST";
string strconn="Data Source=TEST_ACCESS;trusted_connection=True";

OdbcConnection conn = new OdbcConnection(strconn);
OdbcDataAdapter adp = new OdbcDataAdapter(strSQL, conn);

DataSet ds = new DataSet();
adp.Fill(ds, "TEST");
DG1.DataSource = ds.Tables["TEST"];
DG1.DataBind();
}
</Script>

</head>
<body>
<center>
<asp:datagrid id="DG1" runat="server" />
</center>

If succeed, you will see this sentence.

</body>
</html>



William (Bill) Vaughn said:
If you want to access an ODBC data source, you can't use the OLE DB MSDASQL
provider (the Kagera bridge provider) as it's not supported by .NET.
Actually, you don't need a "Provider=" keyword in the connection string for
the Odbc provider.
I also suspect you'll need some sort of security setting in the connection
string (UID=xx;pwd=yy;) or SSPI security.

string strconn="Data Source=TEST_ACCESS;trusted_connection=True";

I would also include a Try/Catch block around the code to trap the
exceptions and return more meaningful messages.

hth


--
____________________________________
Bill Vaughn
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

Tao Lei said:
Please:
I wrote these lines of codes of ASP.Net. But it goes wrong.
Why??? Who can help me?
Thank you very much!!!

<% @Page Language="C#"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Odbc" %>

<html>
<head>
<Script runat="server">
void page_Load(Object Source, EventArgs E)
{
string strSQL="select * from TEST";
string strconn="Provider=MSDASQL.1;Persist Security Info=false;Data
Source=TEST_ACCESS";

OdbcConnection conn = new OdbcConnection(strconn);
OdbcDataAdapter adp = new OdbcDataAdapter(strSQL, conn);

DataSet ds = new DataSet();
adp.Fill(ds, "TEST");
DG1.DataSource = ds.Tables["TEST"];
DG1.DataBind();
}
</Script>

</head>
<body>
<center>
<asp:datagrid id="DG1" runat="server" />
</center>


The exception information are here

System.Data.Odbc.OdbcException : ERROR [IM002] [Microsoft][ODBC Driver
Manager] Data source name not found and no default driver specified
 
W

William \(Bill\) Vaughn

How is it failing? What error is being returned.

--
____________________________________
Bill Vaughn
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

Tao Lei said:
Hello William:
I have not set any password or userID.(They would be empty string)
I only set up a System DSN named TEST_ACCESS in ODBC, there is no homonymy
DSN in User DSN. I also find no .ldb file in my system.
Fllowing your opinion, I write these codes, however, the result is the
same as usual ,why ???
Thank you.

<% @Page Language="C#"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Odbc" %>

<html>
<head>
<Script runat="server">
void page_Load(Object Source, EventArgs E)
{
string strSQL="select * from TEST";
string strconn="Data Source=TEST_ACCESS;trusted_connection=True";

OdbcConnection conn = new OdbcConnection(strconn);
OdbcDataAdapter adp = new OdbcDataAdapter(strSQL, conn);

DataSet ds = new DataSet();
adp.Fill(ds, "TEST");
DG1.DataSource = ds.Tables["TEST"];
DG1.DataBind();
}
</Script>

</head>
<body>
<center>
<asp:datagrid id="DG1" runat="server" />
</center>

If succeed, you will see this sentence.

</body>
</html>



William (Bill) Vaughn said:
If you want to access an ODBC data source, you can't use the OLE DB MSDASQL
provider (the Kagera bridge provider) as it's not supported by .NET.
Actually, you don't need a "Provider=" keyword in the connection string for
the Odbc provider.
I also suspect you'll need some sort of security setting in the connection
string (UID=xx;pwd=yy;) or SSPI security.

string strconn="Data Source=TEST_ACCESS;trusted_connection=True";

I would also include a Try/Catch block around the code to trap the
exceptions and return more meaningful messages.

hth


--
____________________________________
Bill Vaughn
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

Tao Lei said:
Please:
I wrote these lines of codes of ASP.Net. But it goes wrong.
Why??? Who can help me?
Thank you very much!!!

<% @Page Language="C#"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Odbc" %>

<html>
<head>
<Script runat="server">
void page_Load(Object Source, EventArgs E)
{
string strSQL="select * from TEST";
string strconn="Provider=MSDASQL.1;Persist Security Info=false;Data
Source=TEST_ACCESS";

OdbcConnection conn = new OdbcConnection(strconn);
OdbcDataAdapter adp = new OdbcDataAdapter(strSQL, conn);

DataSet ds = new DataSet();
adp.Fill(ds, "TEST");
DG1.DataSource = ds.Tables["TEST"];
DG1.DataBind();
}
</Script>

</head>
<body>
<center>
<asp:datagrid id="DG1" runat="server" />
</center>


The exception information are here

System.Data.Odbc.OdbcException : ERROR [IM002] [Microsoft][ODBC Driver
Manager] Data source name not found and no default driver specified
 
T

Tao Lei

The exception information are here:

System.Data.Odbc.OdbcException : ERROR [IM002] [Microsoft][ODBC Driver
Manager] Data source name not found and no default driver specified


William (Bill) Vaughn said:
How is it failing? What error is being returned.

--
____________________________________
Bill Vaughn
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

Tao Lei said:
Hello William:
I have not set any password or userID.(They would be empty string)
I only set up a System DSN named TEST_ACCESS in ODBC, there is no homonymy
DSN in User DSN. I also find no .ldb file in my system.
Fllowing your opinion, I write these codes, however, the result is the
same as usual ,why ???
Thank you.

<% @Page Language="C#"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Odbc" %>

<html>
<head>
<Script runat="server">
void page_Load(Object Source, EventArgs E)
{
string strSQL="select * from TEST";
string strconn="Data Source=TEST_ACCESS;trusted_connection=True";

OdbcConnection conn = new OdbcConnection(strconn);
OdbcDataAdapter adp = new OdbcDataAdapter(strSQL, conn);

DataSet ds = new DataSet();
adp.Fill(ds, "TEST");
DG1.DataSource = ds.Tables["TEST"];
DG1.DataBind();
}
</Script>

</head>
<body>
<center>
<asp:datagrid id="DG1" runat="server" />
</center>

If succeed, you will see this sentence.

</body>
</html>



William (Bill) Vaughn said:
If you want to access an ODBC data source, you can't use the OLE DB MSDASQL
provider (the Kagera bridge provider) as it's not supported by .NET.
Actually, you don't need a "Provider=" keyword in the connection
string
for
the Odbc provider.
I also suspect you'll need some sort of security setting in the connection
string (UID=xx;pwd=yy;) or SSPI security.

string strconn="Data Source=TEST_ACCESS;trusted_connection=True";

I would also include a Try/Catch block around the code to trap the
exceptions and return more meaningful messages.

hth


--
____________________________________
Bill Vaughn
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

Please:
I wrote these lines of codes of ASP.Net. But it goes wrong.
Why??? Who can help me?
Thank you very much!!!

<% @Page Language="C#"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Odbc" %>

<html>
<head>
<Script runat="server">
void page_Load(Object Source, EventArgs E)
{
string strSQL="select * from TEST";
string strconn="Provider=MSDASQL.1;Persist Security Info=false;Data
Source=TEST_ACCESS";

OdbcConnection conn = new OdbcConnection(strconn);
OdbcDataAdapter adp = new OdbcDataAdapter(strSQL, conn);

DataSet ds = new DataSet();
adp.Fill(ds, "TEST");
DG1.DataSource = ds.Tables["TEST"];
DG1.DataBind();
}
</Script>

</head>
<body>
<center>
<asp:datagrid id="DG1" runat="server" />
</center>


The exception information are here

System.Data.Odbc.OdbcException : ERROR [IM002] [Microsoft][ODBC Driver
Manager] Data source name not found and no default driver specified
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top