|
 |
aspx_beginners thread: connect to SQL with ASP.net using C#
Message #1 by "Bob Sly" <thereaper@a...> on Sat, 14 Sep 2002 00:50:24
|
|
I am trying to connect to an online SQL database with ASP.net using C#
I just get a server error when running the following code
Please have a look and see if you can find what the problem might be.
Do I need to make some sort of reference to the DSN like I do with ASP?
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<html>
<head>
<title>Using a DataReader</title>
<script language="C#" runat="server">
void Page_Load()
{
string connectionStr =
@"server=thor.worldonline.co.za;uid=myuserid;pwd=mypassword;trusted_connect
ion=true;database=jhbdev";
string queryStr = "SELECT * FROM Employee";
SqlConnection connectObj = new SqlConnection(connectionStr);
SqlCommand commandObj = new SqlCommand(queryStr,connectObj);
SqlDataReader readerObj;
connectObj.Open();
readerObj=commandObj.ExecuteReader();
dataGridControl.DataSource = readerObj;
dataGridControl.DataBind();
}
</script>
</head>
<body>
<h2>Using a DataReader</h2>
<asp:DataGrid id="dataGridControl" runat="server" />
</body>
</html>
Message #2 by miss ruby <unix_box@y...> on Fri, 13 Sep 2002 20:43:45 -0700 (PDT)
|
|
Hi bob.. your coding is good. I cannot find where is
the error. Can you give me the error information and
which line the error occured???
TQ
--- Bob Sly <thereaper@a...> wrote:
> I am trying to connect to an online SQL database
> with ASP.net using C#
> I just get a server error when running the following
> code
> Please have a look and see if you can find what the
> problem might be.
> Do I need to make some sort of reference to the DSN
> like I do with ASP?
>
> <%@ Import Namespace="System.Data" %>
> <%@ Import Namespace="System.Data.SqlClient" %>
>
> <html>
> <head>
>
> <title>Using a DataReader</title>
>
> <script language="C#" runat="server">
>
> void Page_Load()
> {
> string connectionStr =
>
@"server=thor.worldonline.co.za;uid=myuserid;pwd=mypassword;trusted_connect
> ion=true;database=jhbdev";
>
> string queryStr = "SELECT * FROM Employee";
>
> SqlConnection connectObj = new
> SqlConnection(connectionStr);
> SqlCommand commandObj = new
> SqlCommand(queryStr,connectObj);
> SqlDataReader readerObj;
>
> connectObj.Open();
> readerObj=commandObj.ExecuteReader();
>
> dataGridControl.DataSource = readerObj;
>
> dataGridControl.DataBind();
>
> }
>
> </script>
> </head>
> <body>
>
> <h2>Using a DataReader</h2>
>
> <asp:DataGrid id="dataGridControl" runat="server"
> />
>
> </body>
> </html>
> ---
> Beginning ASP.NET Databases using VB.NET
> http://www.wrox.com/ACON11.asp?ISBN=1861006195
>
> Beginning ASP.NET Databases using C#
> http://www.wrox.com/ACON11.asp?ISBN=1861007418
>
> These books look at how we can create data-centric
> ASP.NET
> applications. Requiring some basic knowledge of
> ASP.NET,
> Access and SQL the authors guide you through the
> process
> of connecting and consuming information in a variety
> of
> ways. They are packed full of excellent illustrative
> code
> examples, demonstrating important fundamental
> principles.
=====
miss ruby
malaysia
__________________________________________________
Do you Yahoo!?
Yahoo! News - Today's headlines
http://news.yahoo.com
Message #3 by "Bob Sly" <thereaper@a...> on Sat, 14 Sep 2002 15:42:18
|
|
Thanks for the reply!
I wish I could.
It does not give a line error.
It looks like an internal server error.
I checked the database by connecting via a normal ASP script using ADODB
and all is well. It's just with ASP.Net that I have this problem. My
Hosting server definately supports ASP.Net as I have many other C# scripts
running on the same server. Could the problem lie on the server side? What
can I check? How does the DSN fit into the picture with ASP.Net?
> Hi bob.. your coding is good. I cannot find where is
the error. Can you give me the error information and
which line the error occured???
TQ
--- Bob Sly <thereaper@a...> wrote:
> I am trying to connect to an online SQL database
> with ASP.net using C#
> I just get a server error when running the following
> code
> Please have a look and see if you can find what the
> problem might be.
> Do I need to make some sort of reference to the DSN
> like I do with ASP?
>
> <%@ Import Namespace="System.Data" %>
> <%@ Import Namespace="System.Data.SqlClient" %>
>
> <html>
> <head>
>
> <title>Using a DataReader</title>
>
> <script language="C#" runat="server">
>
> void Page_Load()
> {
> string connectionStr =
>
@"server=thor.worldonline.co.za;uid=myuserid;pwd=mypassword;trusted_connect
> ion=true;database=jhbdev";
>
> string queryStr = "SELECT * FROM Employee";
>
> SqlConnection connectObj = new
> SqlConnection(connectionStr);
> SqlCommand commandObj = new
> SqlCommand(queryStr,connectObj);
> SqlDataReader readerObj;
>
> connectObj.Open();
> readerObj=commandObj.ExecuteReader();
>
> dataGridControl.DataSource = readerObj;
>
> dataGridControl.DataBind();
>
> }
>
> </script>
> </head>
> <body>
>
> <h2>Using a DataReader</h2>
>
> <asp:DataGrid id="dataGridControl" runat="server"
> />
>
> </body>
> </html>
> ---
> Beginning ASP.NET Databases using VB.NET
> http://www.wrox.com/ACON11.asp?ISBN=1861006195
>
> Beginning ASP.NET Databases using C#
> http://www.wrox.com/ACON11.asp?ISBN=1861007418
>
> These books look at how we can create data-centric
> ASP.NET
> applications. Requiring some basic knowledge of
> ASP.NET,
> Access and SQL the authors guide you through the
> process
> of connecting and consuming information in a variety
> of
> ways. They are packed full of excellent illustrative
> code
> examples, demonstrating important fundamental
> principles.
=====
miss ruby
malaysia
__________________________________________________
Do you Yahoo!?
Yahoo! News - Today's headlines
http://news.yahoo.com
Message #4 by Imar Spaanjaars <Imar@S...> on Sat, 14 Sep 2002 16:45:10 +0200
|
|
What error are you receiving exactly? Did you turn off "Friendly HTTP Error
Messages" on the Advanced tab of the Internet Explorer Options dialog?
This shows a general error page whenever the server returns an error,
instead of showing the actual error message sent by the server.
Also, you are using "trusted_connection" is true in your connection string.
Are you sure this is what you want? Does your SQL Server require this? If
not, leave out the trusted connection option from the connection string and
just use the UserID and password.
HtH
Imar
At 03:42 PM 9/14/2002 +0000, you wrote:
>Thanks for the reply!
>
>I wish I could.
>It does not give a line error.
>It looks like an internal server error.
>I checked the database by connecting via a normal ASP script using ADODB
>and all is well. It's just with ASP.Net that I have this problem. My
>Hosting server definately supports ASP.Net as I have many other C# scripts
>running on the same server. Could the problem lie on the server side? What
>can I check? How does the DSN fit into the picture with ASP.Net?
>
>
> > Hi bob.. your coding is good. I cannot find where is
>the error. Can you give me the error information and
>which line the error occured???
>
>TQ
>
>
>
>--- Bob Sly <thereaper@a...> wrote:
> > I am trying to connect to an online SQL database
> > with ASP.net using C#
> > I just get a server error when running the following
> > code
> > Please have a look and see if you can find what the
> > problem might be.
> > Do I need to make some sort of reference to the DSN
> > like I do with ASP?
> >
> > <%@ Import Namespace="System.Data" %>
> > <%@ Import Namespace="System.Data.SqlClient" %>
> >
> > <html>
> > <head>
> >
> > <title>Using a DataReader</title>
> >
> > <script language="C#" runat="server">
> >
> > void Page_Load()
> > {
> > string connectionStr
> >
>@"server=thor.worldonline.co.za;uid=myuserid;pwd=mypassword;trusted_connect
> > ion=true;database=jhbdev";
> >
> > string queryStr = "SELECT * FROM Employee";
> >
> > SqlConnection connectObj = new
> > SqlConnection(connectionStr);
> > SqlCommand commandObj = new
> > SqlCommand(queryStr,connectObj);
> > SqlDataReader readerObj;
> >
> > connectObj.Open();
> > readerObj=commandObj.ExecuteReader();
> >
> > dataGridControl.DataSource = readerObj;
> >
> > dataGridControl.DataBind();
> >
> > }
> >
> > </script>
> > </head>
> > <body>
> >
> > <h2>Using a DataReader</h2>
> >
> > <asp:DataGrid id="dataGridControl" runat="server"
> > />
> >
> > </body>
> > </html>
> > ---
> > Beginning ASP.NET Databases using VB.NET
> > http://www.wrox.com/ACON11.asp?ISBN=1861006195
> >
> > Beginning ASP.NET Databases using C#
> > http://www.wrox.com/ACON11.asp?ISBN=1861007418
> >
> > These books look at how we can create data-centric
> > ASP.NET
> > applications. Requiring some basic knowledge of
> > ASP.NET,
> > Access and SQL the authors guide you through the
> > process
> > of connecting and consuming information in a variety
> > of
> > ways. They are packed full of excellent illustrative
> > code
> > examples, demonstrating important fundamental
> > principles.
>
>
>=====
>miss ruby
>malaysia
>
>__________________________________________________
>Do you Yahoo!?
>Yahoo! News - Today's headlines
>http://news.yahoo.com
>---
>Beginning ASP.NET Databases using VB.NET
>http://www.wrox.com/ACON11.asp?ISBN=1861006195
>
>Beginning ASP.NET Databases using C#
>http://www.wrox.com/ACON11.asp?ISBN=1861007418
>
>These books look at how we can create data-centric ASP.NET
>applications. Requiring some basic knowledge of ASP.NET,
>Access and SQL the authors guide you through the process
>of connecting and consuming information in a variety of
>ways. They are packed full of excellent illustrative code
>examples, demonstrating important fundamental principles.
Message #5 by miss ruby <unix_box@y...> on Mon, 16 Sep 2002 01:42:16 -0700 (PDT)
|
|
eemm... by the way bob...how about running the page on
your local machine . it's error occured or not??
--- Bob Sly <thereaper@a...> wrote:
> Thanks for the reply!
>
> I wish I could.
> It does not give a line error.
> It looks like an internal server error.
> I checked the database by connecting via a normal
> ASP script using ADODB
> and all is well. It's just with ASP.Net that I have
> this problem. My
> Hosting server definately supports ASP.Net as I have
> many other C# scripts
> running on the same server. Could the problem lie on
> the server side? What
> can I check? How does the DSN fit into the picture
> with ASP.Net?
>
>
> > Hi bob.. your coding is good. I cannot find where
> is
> the error. Can you give me the error information and
> which line the error occured???
>
> TQ
>
>
>
> --- Bob Sly <thereaper@a...> wrote:
> > I am trying to connect to an online SQL database
> > with ASP.net using C#
> > I just get a server error when running the
> following
> > code
> > Please have a look and see if you can find what
> the
> > problem might be.
> > Do I need to make some sort of reference to the
> DSN
> > like I do with ASP?
> >
> > <%@ Import Namespace="System.Data" %>
> > <%@ Import Namespace="System.Data.SqlClient" %>
> >
> > <html>
> > <head>
> >
> > <title>Using a DataReader</title>
> >
> > <script language="C#" runat="server">
> >
> > void Page_Load()
> > {
> > string connectionStr =
> >
>
@"server=thor.worldonline.co.za;uid=myuserid;pwd=mypassword;trusted_connect
> > ion=true;database=jhbdev";
> >
> > string queryStr = "SELECT * FROM Employee";
> >
> > SqlConnection connectObj = new
> > SqlConnection(connectionStr);
> > SqlCommand commandObj = new
> > SqlCommand(queryStr,connectObj);
> > SqlDataReader readerObj;
> >
> > connectObj.Open();
> > readerObj=commandObj.ExecuteReader();
> >
> > dataGridControl.DataSource = readerObj;
> >
> > dataGridControl.DataBind();
> >
> > }
> >
> > </script>
> > </head>
> > <body>
> >
> > <h2>Using a DataReader</h2>
> >
> > <asp:DataGrid id="dataGridControl" runat="server"
> > />
> >
> > </body>
> > </html>
> > ---
> > Beginning ASP.NET Databases using VB.NET
> > http://www.wrox.com/ACON11.asp?ISBN=1861006195
> >
> > Beginning ASP.NET Databases using C#
> > http://www.wrox.com/ACON11.asp?ISBN=1861007418
> >
> > These books look at how we can create data-centric
> > ASP.NET
> > applications. Requiring some basic knowledge of
> > ASP.NET,
> > Access and SQL the authors guide you through the
> > process
> > of connecting and consuming information in a
> variety
> > of
> > ways. They are packed full of excellent
> illustrative
> > code
> > examples, demonstrating important fundamental
> > principles.
>
>
> =====
> miss ruby
> malaysia
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! News - Today's headlines
> http://news.yahoo.com
> ---
> Beginning ASP.NET Databases using VB.NET
> http://www.wrox.com/ACON11.asp?ISBN=1861006195
>
> Beginning ASP.NET Databases using C#
> http://www.wrox.com/ACON11.asp?ISBN=1861007418
>
> These books look at how we can create data-centric
> ASP.NET
> applications. Requiring some basic knowledge of
> ASP.NET,
> Access and SQL the authors guide you through the
> process
> of connecting and consuming information in a variety
> of
> ways. They are packed full of excellent illustrative
> code
> examples, demonstrating important fundamental
> principles.
=====
miss ruby
malaysia
__________________________________________________
Do you Yahoo!?
Yahoo! News - Today's headlines
http://news.yahoo.com
Message #6 by "Bob Sly" <thereaper@a...> on Mon, 16 Sep 2002 23:12:18
|
|
Thanks alot for the "Friendly HTTP Error Message" tip,
that will really make my debugging easier in the future.
I get a Runtime Error
Description: An application error occurred on the server. The current
custom error settings for this application prevent the details of the
application error from being viewed remotely (for security reasons).
I'll contact my sysadmin and ask him to run it on the local machine to see
if he can get a more detailed error message.
> What error are you receiving exactly? Did you turn off "Friendly HTTP
Error
Messages" on the Advanced tab of the Internet Explorer Options dialog?
This shows a general error page whenever the server returns an error,
instead of showing the actual error message sent by the server.
Also, you are using "trusted_connection" is true in your connection
string.
Are you sure this is what you want? Does your SQL Server require this? If
not, leave out the trusted connection option from the connection string
and
just use the UserID and password.
HtH
Imar
At 03:42 PM 9/14/2002 +0000, you wrote:
>Thanks for the reply!
>
>I wish I could.
>It does not give a line error.
>It looks like an internal server error.
>I checked the database by connecting via a normal ASP script using ADODB
>and all is well. It's just with ASP.Net that I have this problem. My
>Hosting server definately supports ASP.Net as I have many other C# scripts
>running on the same server. Could the problem lie on the server side? What
>can I check? How does the DSN fit into the picture with ASP.Net?
>
>
> > Hi bob.. your coding is good. I cannot find where is
>the error. Can you give me the error information and
>which line the error occured???
>
>TQ
>
>
>
>--- Bob Sly <thereaper@a...> wrote:
> > I am trying to connect to an online SQL database
> > with ASP.net using C#
> > I just get a server error when running the following
> > code
> > Please have a look and see if you can find what the
> > problem might be.
> > Do I need to make some sort of reference to the DSN
> > like I do with ASP?
> >
> > <%@ Import Namespace="System.Data" %>
> > <%@ Import Namespace="System.Data.SqlClient" %>
> >
> > <html>
> > <head>
> >
> > <title>Using a DataReader</title>
> >
> > <script language="C#" runat="server">
> >
> > void Page_Load()
> > {
> > string connectionStr
> >
>@"server=thor.worldonline.co.za;uid=myuserid;pwd=mypassword;trusted_connec
t
> > ion=true;database=jhbdev";
> >
> > string queryStr = "SELECT * FROM Employee";
> >
> > SqlConnection connectObj = new
> > SqlConnection(connectionStr);
> > SqlCommand commandObj = new
> > SqlCommand(queryStr,connectObj);
> > SqlDataReader readerObj;
> >
> > connectObj.Open();
> > readerObj=commandObj.ExecuteReader();
> >
> > dataGridControl.DataSource = readerObj;
> >
> > dataGridControl.DataBind();
> >
> > }
> >
> > </script>
> > </head>
> > <body>
> >
> > <h2>Using a DataReader</h2>
> >
> > <asp:DataGrid id="dataGridControl" runat="server"
> > />
> >
> > </body>
> > </html>
> > ---
> > Beginning ASP.NET Databases using VB.NET
> > http://www.wrox.com/ACON11.asp?ISBN=1861006195
> >
> > Beginning ASP.NET Databases using C#
> > http://www.wrox.com/ACON11.asp?ISBN=1861007418
> >
> > These books look at how we can create data-centric
> > ASP.NET
> > applications. Requiring some basic knowledge of
> > ASP.NET,
> > Access and SQL the authors guide you through the
> > process
> > of connecting and consuming information in a variety
> > of
> > ways. They are packed full of excellent illustrative
> > code
> > examples, demonstrating important fundamental
> > principles.
>
>
>=====
>miss ruby
>malaysia
>
>__________________________________________________
>Do you Yahoo!?
>Yahoo! News - Today's headlines
>http://news.yahoo.com
>---
>Beginning ASP.NET Databases using VB.NET
>http://www.wrox.com/ACON11.asp?ISBN=1861006195
>
>Beginning ASP.NET Databases using C#
>http://www.wrox.com/ACON11.asp?ISBN=1861007418
>
>These books look at how we can create data-centric ASP.NET
>applications. Requiring some basic knowledge of ASP.NET,
>Access and SQL the authors guide you through the process
>of connecting and consuming information in a variety of
>ways. They are packed full of excellent illustrative code
>examples, demonstrating important fundamental principles.
Message #7 by "Bob Sly" <thereaper@a...> on Mon, 16 Sep 2002 23:18:58
|
|
Unfortunately I dont have SQL7 running on my local machine.
>
eemm... by the way bob...how about running the page on
your local machine . it's error occured or not??
--- Bob Sly <thereaper@a...> wrote:
> Thanks for the reply!
>
> I wish I could.
> It does not give a line error.
> It looks like an internal server error.
> I checked the database by connecting via a normal
> ASP script using ADODB
> and all is well. It's just with ASP.Net that I have
> this problem. My
> Hosting server definately supports ASP.Net as I have
> many other C# scripts
> running on the same server. Could the problem lie on
> the server side? What
> can I check? How does the DSN fit into the picture
> with ASP.Net?
>
>
> > Hi bob.. your coding is good. I cannot find where
> is
> the error. Can you give me the error information and
> which line the error occured???
>
> TQ
>
>
>
> --- Bob Sly <thereaper@a...> wrote:
> > I am trying to connect to an online SQL database
> > with ASP.net using C#
> > I just get a server error when running the
> following
> > code
> > Please have a look and see if you can find what
> the
> > problem might be.
> > Do I need to make some sort of reference to the
> DSN
> > like I do with ASP?
> >
> > <%@ Import Namespace="System.Data" %>
> > <%@ Import Namespace="System.Data.SqlClient" %>
> >
> > <html>
> > <head>
> >
> > <title>Using a DataReader</title>
> >
> > <script language="C#" runat="server">
> >
> > void Page_Load()
> > {
> > string connectionStr =
> >
>
@"server=thor.worldonline.co.za;uid=myuserid;pwd=mypassword;trusted_connect
> > ion=true;database=jhbdev";
> >
> > string queryStr = "SELECT * FROM Employee";
> >
> > SqlConnection connectObj = new
> > SqlConnection(connectionStr);
> > SqlCommand commandObj = new
> > SqlCommand(queryStr,connectObj);
> > SqlDataReader readerObj;
> >
> > connectObj.Open();
> > readerObj=commandObj.ExecuteReader();
> >
> > dataGridControl.DataSource = readerObj;
> >
> > dataGridControl.DataBind();
> >
> > }
> >
> > </script>
> > </head>
> > <body>
> >
> > <h2>Using a DataReader</h2>
> >
> > <asp:DataGrid id="dataGridControl" runat="server"
> > />
> >
> > </body>
> > </html>
> > ---
> > Beginning ASP.NET Databases using VB.NET
> > http://www.wrox.com/ACON11.asp?ISBN=1861006195
> >
> > Beginning ASP.NET Databases using C#
> > http://www.wrox.com/ACON11.asp?ISBN=1861007418
> >
> > These books look at how we can create data-centric
> > ASP.NET
> > applications. Requiring some basic knowledge of
> > ASP.NET,
> > Access and SQL the authors guide you through the
> > process
> > of connecting and consuming information in a
> variety
> > of
> > ways. They are packed full of excellent
> illustrative
> > code
> > examples, demonstrating important fundamental
> > principles.
>
>
> =====
> miss ruby
> malaysia
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! News - Today's headlines
> http://news.yahoo.com
> ---
> Beginning ASP.NET Databases using VB.NET
> http://www.wrox.com/ACON11.asp?ISBN=1861006195
>
> Beginning ASP.NET Databases using C#
> http://www.wrox.com/ACON11.asp?ISBN=1861007418
>
> These books look at how we can create data-centric
> ASP.NET
> applications. Requiring some basic knowledge of
> ASP.NET,
> Access and SQL the authors guide you through the
> process
> of connecting and consuming information in a variety
> of
> ways. They are packed full of excellent illustrative
> code
> examples, demonstrating important fundamental
> principles.
=====
miss ruby
malaysia
__________________________________________________
Do you Yahoo!?
Yahoo! News - Today's headlines
http://news.yahoo.com
Message #8 by Imar Spaanjaars <Imar@S...> on Tue, 17 Sep 2002 00:30:39 +0200
|
|
If applicable, allowed etc, your sysadmin could change this:
<customErrors mode="RemoteOnly" defaultRedirect="showError.aspx" />
to this:
<customErrors mode="Off" defaultRedirect="showError.aspx" />
in the web.config file in the root of your site so you could also see the
error remotely. This will always dump errors to the screen. Not recommended
for production machines though.
Another approach for "remote debugging" is to use the Application_OnError
event in the global.asax to send yourself an e-mail message with detailed
error info.
Cheers,
Imar
At 11:12 PM 9/16/2002 +0000, you wrote:
>Thanks alot for the "Friendly HTTP Error Message" tip,
>that will really make my debugging easier in the future.
>
>I get a Runtime Error
>Description: An application error occurred on the server. The current
>custom error settings for this application prevent the details of the
>application error from being viewed remotely (for security reasons).
>
>I'll contact my sysadmin and ask him to run it on the local machine to see
>if he can get a more detailed error message.
>
>
>
> > What error are you receiving exactly? Did you turn off "Friendly HTTP
>Error
>Messages" on the Advanced tab of the Internet Explorer Options dialog?
>
>This shows a general error page whenever the server returns an error,
>instead of showing the actual error message sent by the server.
>
>Also, you are using "trusted_connection" is true in your connection
>string.
>Are you sure this is what you want? Does your SQL Server require this? If
>not, leave out the trusted connection option from the connection string
>and
>just use the UserID and password.
>
>
>HtH
>
>Imar
>
>
>
>At 03:42 PM 9/14/2002 +0000, you wrote:
> >Thanks for the reply!
> >
> >I wish I could.
> >It does not give a line error.
> >It looks like an internal server error.
> >I checked the database by connecting via a normal ASP script using ADODB
> >and all is well. It's just with ASP.Net that I have this problem. My
> >Hosting server definately supports ASP.Net as I have many other C# scripts
> >running on the same server. Could the problem lie on the server side? What
> >can I check? How does the DSN fit into the picture with ASP.Net?
> >
> >
> > > Hi bob.. your coding is good. I cannot find where is
> >the error. Can you give me the error information and
> >which line the error occured???
> >
> >TQ
> >
> >
> >
> >--- Bob Sly <thereaper@a...> wrote:
> > > I am trying to connect to an online SQL database
> > > with ASP.net using C#
> > > I just get a server error when running the following
> > > code
> > > Please have a look and see if you can find what the
> > > problem might be.
> > > Do I need to make some sort of reference to the DSN
> > > like I do with ASP?
> > >
> > > <%@ Import Namespace="System.Data" %>
> > > <%@ Import Namespace="System.Data.SqlClient" %>
> > >
> > > <html>
> > > <head>
> > >
> > > <title>Using a DataReader</title>
> > >
> > > <script language="C#" runat="server">
> > >
> > > void Page_Load()
> > > {
> > > string connectionStr
> > >
> >@"server=thor.worldonline.co.za;uid=myuserid;pwd=mypassword;trusted_connec
>t
> > > ion=true;database=jhbdev";
> > >
> > > string queryStr = "SELECT * FROM Employee";
> > >
> > > SqlConnection connectObj = new
> > > SqlConnection(connectionStr);
> > > SqlCommand commandObj = new
> > > SqlCommand(queryStr,connectObj);
> > > SqlDataReader readerObj;
> > >
> > > connectObj.Open();
> > > readerObj=commandObj.ExecuteReader();
> > >
> > > dataGridControl.DataSource = readerObj;
> > >
> > > dataGridControl.DataBind();
> > >
> > > }
> > >
> > > </script>
> > > </head>
> > > <body>
> > >
> > > <h2>Using a DataReader</h2>
> > >
> > > <asp:DataGrid id="dataGridControl" runat="server"
> > > />
> > >
> > > </body>
> > > </html>
> > > ---
> > > Beginning ASP.NET Databases using VB.NET
> > > http://www.wrox.com/ACON11.asp?ISBN=1861006195
> > >
> > > Beginning ASP.NET Databases using C#
> > > http://www.wrox.com/ACON11.asp?ISBN=1861007418
> > >
> > > These books look at how we can create data-centric
> > > ASP.NET
> > > applications. Requiring some basic knowledge of
> > > ASP.NET,
> > > Access and SQL the authors guide you through the
> > > process
> > > of connecting and consuming information in a variety
> > > of
> > > ways. They are packed full of excellent illustrative
> > > code
> > > examples, demonstrating important fundamental
> > > principles.
> >
> >
> >=====
> >miss ruby
> >malaysia
> >
|
|
 |