asp.net and sql server

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

how to connection sql server table with aspx like pulling data from table to
grid view.... simple example to start ....
thanks
 
how to connection sql server table with aspx like pulling data from
table to grid view.... simple example to start ....

For such a basic example, I suggest you do a google search on "SQL ASP.NET
tutorial"
 
On "Microsoft Visual Studio 2005 Documentation" look for:

Visual Web Developer
Walkthrough: Basic Data Access in Web Pages

<Harvey Triana />
 
I have used the link below and try to run the example
"http://samples.gotdotnet.com/quicks...a/datagrid1.src&file=CS\datagrid1.aspx&font=3"
but it giving me the error i dont have any idea whats wrong seem to be olrite
but still got error my sqlserver is on ip 10.0.0.2
here is the connection string
SqlConnection myConnection = new
SqlConnection("server=10.0.0.2;database=MyDatabase;Trusted_Connection=yes");
SqlDataAdapter myCommand = new SqlDataAdapter("select * from Authors",
myConnection);

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

MyDataGrid.DataSource=ds.Tables["Authors"].DefaultView;
MyDataGrid.DataBind();
any one has any idea whats wrong thanks
 
You haven't opened the connection anywhere.

I have used the link below and try to run the example
"http://samples.gotdotnet.com/quicks...a/datagrid1.src&file=CS\datagrid1.aspx&font=3"
but it giving me the error i dont have any idea whats wrong seem to be olrite
but still got error my sqlserver is on ip 10.0.0.2
here is the connection string
SqlConnection myConnection = new
SqlConnection("server=10.0.0.2;database=MyDatabase;Trusted_Connection=yes");
SqlDataAdapter myCommand = new SqlDataAdapter("select * from Authors",
myConnection);

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

MyDataGrid.DataSource=ds.Tables["Authors"].DefaultView;
MyDataGrid.DataBind();
any one has any idea whats wrong thanks
Juan T. Llibre said:
For SQL Server 2000 / ASP.NET 1.1 :

http://samples.gotdotnet.com/quickstart/aspplus/

For SQL Server 2005 / ASP.NET 2.0 :

http://asp.net/QuickStart/aspnet/doc/data/default.aspx




Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
 
re:
but still got error my sqlserver is on ip 10.0.0.2
("server=10.0.0.2;database=MyDatabase;Trusted_Connection=yes");

Is the SQL Server (2000 or MSDE?) on the same computer as your web server ?
If so, use the SQL Server's instance name, not the IP, in the connection.

SqlConnection("server=MachineName\NetSDK;UID=username;database=DBName;PWD=password");
or
SqlConnection("server=MachineName\NetSDK;database=MyDatabase;Trusted_Connection=yes");
( MachineName\NetSDK is the default instance name for MSDE/SQL Server 2000 )

or
SqlConnection("server=SqlServerInstanceName;database=MyDatabase;Trusted_Connection=yes");

If you're using Sql Server 2005, or Sql Server Express 2005, it's a bit different than this.




Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
amjad said:
I have used the link below and try to run the example
"http://samples.gotdotnet.com/quicks...a/datagrid1.src&file=CS\datagrid1.aspx&font=3"
but it giving me the error i dont have any idea whats wrong seem to be olrite
but still got error my sqlserver is on ip 10.0.0.2
here is the connection string
SqlConnection myConnection = new
SqlConnection("server=10.0.0.2;database=MyDatabase;Trusted_Connection=yes");
SqlDataAdapter myCommand = new SqlDataAdapter("select * from Authors",
myConnection);

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

MyDataGrid.DataSource=ds.Tables["Authors"].DefaultView;
MyDataGrid.DataBind();
any one has any idea whats wrong thanks
Juan T. Llibre said:
For SQL Server 2000 / ASP.NET 1.1 :

http://samples.gotdotnet.com/quickstart/aspplus/

For SQL Server 2005 / ASP.NET 2.0 :

http://asp.net/QuickStart/aspnet/doc/data/default.aspx




Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
 
forget to mention tat i am using sql server 2005

Juan T. Llibre said:
re:
but still got error my sqlserver is on ip 10.0.0.2
("server=10.0.0.2;database=MyDatabase;Trusted_Connection=yes");

Is the SQL Server (2000 or MSDE?) on the same computer as your web server ?
If so, use the SQL Server's instance name, not the IP, in the connection.

SqlConnection("server=MachineName\NetSDK;UID=username;database=DBName;PWD=password");
or
SqlConnection("server=MachineName\NetSDK;database=MyDatabase;Trusted_Connection=yes");
( MachineName\NetSDK is the default instance name for MSDE/SQL Server 2000 )

or
SqlConnection("server=SqlServerInstanceName;database=MyDatabase;Trusted_Connection=yes");

If you're using Sql Server 2005, or Sql Server Express 2005, it's a bit different than this.




Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
amjad said:
I have used the link below and try to run the example
"http://samples.gotdotnet.com/quicks...a/datagrid1.src&file=CS\datagrid1.aspx&font=3"
but it giving me the error i dont have any idea whats wrong seem to be olrite
but still got error my sqlserver is on ip 10.0.0.2
here is the connection string
SqlConnection myConnection = new
SqlConnection("server=10.0.0.2;database=MyDatabase;Trusted_Connection=yes");
SqlDataAdapter myCommand = new SqlDataAdapter("select * from Authors",
myConnection);

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

MyDataGrid.DataSource=ds.Tables["Authors"].DefaultView;
MyDataGrid.DataBind();
any one has any idea whats wrong thanks
Juan T. Llibre said:
For SQL Server 2000 / ASP.NET 1.1 :

http://samples.gotdotnet.com/quickstart/aspplus/

For SQL Server 2005 / ASP.NET 2.0 :

http://asp.net/QuickStart/aspnet/doc/data/default.aspx




Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
how to connection sql server table with aspx like pulling data from table to
grid view.... simple example to start ....
thanks
 
You also forgot to say whether the SQL Server 2005
is on the same computer as your web server.




Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
amjad said:
forget to mention tat i am using sql server 2005

Juan T. Llibre said:
re:
but still got error my sqlserver is on ip 10.0.0.2
("server=10.0.0.2;database=MyDatabase;Trusted_Connection=yes");

Is the SQL Server (2000 or MSDE?) on the same computer as your web server ?
If so, use the SQL Server's instance name, not the IP, in the connection.

SqlConnection("server=MachineName\NetSDK;UID=username;database=DBName;PWD=password");
or
SqlConnection("server=MachineName\NetSDK;database=MyDatabase;Trusted_Connection=yes");
( MachineName\NetSDK is the default instance name for MSDE/SQL Server 2000 )

or
SqlConnection("server=SqlServerInstanceName;database=MyDatabase;Trusted_Connection=yes");

If you're using Sql Server 2005, or Sql Server Express 2005, it's a bit different than this.




Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
amjad said:
I have used the link below and try to run the example
"http://samples.gotdotnet.com/quicks...a/datagrid1.src&file=CS\datagrid1.aspx&font=3"
but it giving me the error i dont have any idea whats wrong seem to be olrite
but still got error my sqlserver is on ip 10.0.0.2
here is the connection string
SqlConnection myConnection = new
SqlConnection("server=10.0.0.2;database=MyDatabase;Trusted_Connection=yes");
SqlDataAdapter myCommand = new SqlDataAdapter("select * from Authors",
myConnection);

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

MyDataGrid.DataSource=ds.Tables["Authors"].DefaultView;
MyDataGrid.DataBind();
any one has any idea whats wrong thanks
:

For SQL Server 2000 / ASP.NET 1.1 :

http://samples.gotdotnet.com/quickstart/aspplus/

For SQL Server 2005 / ASP.NET 2.0 :

http://asp.net/QuickStart/aspnet/doc/data/default.aspx




Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
how to connection sql server table with aspx like pulling data from table to
grid view.... simple example to start ....
thanks
 
You're going to run into problems if you want to use SQL Server 2005
to run the .Net Framework SDK 1.1 data access examples.

1. You need the Pubs database. Is it installed ?

After you've downloaded and installed SQL Server 2005 Express,
if you want to install the sample Pubs and Northwind databases,
double-click the .msi version of the file from the following link:

http://www.microsoft.com/downloads/...12-0356-46a0-8da2-eebc53a68034&displaylang=en

This installs two T-SQL scripts that you must run to build the databases.

You can use either the built-in SQLCMD command line tool or you can use
Query Editor from SQL Server Management Studio.

The following two command examples let you use SQLCMD
to install the sample databases to the local system:

SQLCMD -E -i "C:\PathToTheDownloadedSampleDatabases\instpubs.sql"
SQLCMD -E -i "C:\PathToTheDownloadedSampleDatabases\instnwnd.sql"

SQL Server Management Studio is available at :
http://www.microsoft.com/downloads/...AE-4BD1-4E3D-94B8-5A0F62BF7796&displaylang=en

Microsoft also provides a free SQL Server Express Utility-SSEUtil.

This downloadable tool lets you list all installed instances of SQL Server Express;
connect to an instance; and create, attach, and detach databases as well as execute
SQL statements. Check out SSEUtil at:

http://www.microsoft.com/downloads/...73F-472E-A85C-27ED01CF6B02&displaylang=enMake sure you bookmark this page :http://www.connectionstrings.com/Click on the SQL Server 2005 icon and then on the Sql Connection (.Net ) iconfor a bunch of connection strings for SQL Server Express 2005.Which one is the right one depends on your setup and what you want to do.Good luck!Juan T. Llibre, asp.net MVPaspnetfaq.com : http://www.aspnetfaq.com/asp.net faq : http://asp.net.do/faq/foros de asp.net, en español : http://asp.net.do/foros/==================================="amjad" <[email protected]> wrote in messagenews:[email protected]...> forget to mention tat i am using sql server 2005>> "Juan T. Llibre" wrote:>>> re:>> > but still got error my sqlserver is on ip 10.0.0.2>> > ("server=10.0.0.2;database=MyDatabase;Trusted_Connection=yes");>>>> Is the SQL Server (2000 or MSDE?) on the same computer as your web server ?>> If so, use the SQL Server's instance name, not the IP, in the connection.>>>> SqlConnection("server=MachineName\NetSDK;UID=username;database=DBName;PWD=password");>> or>> SqlConnection("server=MachineName\NetSDK;database=MyDatabase;Trusted_Connection=yes");>> ( MachineName\NetSDK is the default instance name for MSDE/SQL Server 2000 )>>>> or>> SqlConnection("server=SqlServerInstanceName;database=MyDatabase;Trusted_Connection=yes");>>>> If you're using Sql Server 2005, or Sql Server Express 2005, it's a bit different than this.>>>>>>>>>> Juan T. Llibre, asp.net MVP>> aspnetfaq.com : http://www.aspnetfaq.com/>> asp.net faq : http://asp.net.do/faq/>> foros de asp.net, en español : http://asp.net.do/foros/>> ===================================>> "amjad" <[email protected]> wrote in message>> news:[email protected]...>> >I have used the link below and try to run the example>> >"http://samples.gotdotnet.com/quicks...a/datagrid1.src&file=CS\datagrid1.aspx&font=3">> > but it giving me the error i dont have any idea whats wrong seem to be olrite>> > but still got error my sqlserver is on ip 10.0.0.2>> > here is the connection string>> > SqlConnection myConnection = new>> > SqlConnection("server=10.0.0.2;database=MyDatabase;Trusted_Connection=yes");>> > SqlDataAdapter myCommand = new SqlDataAdapter("select * from Authors",>> > myConnection);>> >>> > DataSet ds = new DataSet();>> > myCommand.Fill(ds, "Authors");>> >>> > MyDataGrid.DataSource=ds.Tables["Authors"].DefaultView;>> > MyDataGrid.DataBind();>> > any one has any idea whats wrong thanks>> > "Juan T. Llibre" wrote:>> >>> >> For SQL Server 2000 / ASP.NET 1.1 :>> >>>> >> http://samples.gotdotnet.com/quickstart/aspplus/>> >>>> >> For SQL Server 2005 / ASP.NET 2.0 :>> >>>> >> http://asp.net/QuickStart/aspnet/doc/data/default.aspx>> >>>> >>>> >>>> >>>> >> Juan T. Llibre, asp.net MVP>> >> aspnetfaq.com : http://www.aspnetfaq.com/>> >> asp.net faq : http://asp.net.do/faq/>> >> foros de asp.net, en español : http://asp.net.do/foros/>> >> ===================================>> >> "amjad" <[email protected]> wrote in message>> >> >> > how to connection sql server table with aspx like pulling data from table to>> >> > grid view.... simple example to start ....>> >> > thanks>> >>>> >>>> >>>>>>>>
 
My webserver is on different server and sql server 2005 is on different
server ..i am not using sql express 2005 instead full sql server 2005..
thanks

Juan T. Llibre said:
You're going to run into problems if you want to use SQL Server 2005
to run the .Net Framework SDK 1.1 data access examples.

1. You need the Pubs database. Is it installed ?

After you've downloaded and installed SQL Server 2005 Express,
if you want to install the sample Pubs and Northwind databases,
double-click the .msi version of the file from the following link:

http://www.microsoft.com/downloads/...12-0356-46a0-8da2-eebc53a68034&displaylang=en

This installs two T-SQL scripts that you must run to build the databases.

You can use either the built-in SQLCMD command line tool or you can use
Query Editor from SQL Server Management Studio.

The following two command examples let you use SQLCMD
to install the sample databases to the local system:

SQLCMD -E -i "C:\PathToTheDownloadedSampleDatabases\instpubs.sql"
SQLCMD -E -i "C:\PathToTheDownloadedSampleDatabases\instnwnd.sql"

SQL Server Management Studio is available at :
http://www.microsoft.com/downloads/...AE-4BD1-4E3D-94B8-5A0F62BF7796&displaylang=en

Microsoft also provides a free SQL Server Express Utility-SSEUtil.

This downloadable tool lets you list all installed instances of SQL Server Express;
connect to an instance; and create, attach, and detach databases as well as execute
SQL statements. Check out SSEUtil at:

http://www.microsoft.com/downloads/...73F-472E-A85C-27ED01CF6B02&displaylang=enMake sure you bookmark this page :http://www.connectionstrings.com/Click on the SQL Server 2005 icon and then on the Sql Connection (.Net ) iconfor a bunch of connection strings for SQL Server Express 2005.Which one is the right one depends on your setup and what you want to do.Good luck!Juan T. Llibre, asp.net MVPaspnetfaq.com : http://www.aspnetfaq.com/asp.net faq : http://asp.net.do/faq/foros de asp.net, en español : http://asp.net.do/foros/==================================="amjad" <[email protected]> wrote in messagenews:[email protected]...> forget to mention tat i am using sql server 2005>> "Juan T. Llibre" wrote:>>> re:>> > but still got error my sqlserver is on ip 10.0.0.2>> > ("server=10.0.0.2;database=MyDatabase;Trusted_Connection=yes");>>>> Is the SQL Server (2000 or MSDE?) on the same computer as your web server
"http://samples.gotdotnet.com/quicks...a/datagrid1.src&file=CS\datagrid1.aspx&font=3">> > but it giving me the error i dont have any idea whats wrong seem to be olrite>> > but still got error my sqlserver is on ip 10.0.0.2>> > here is the connection string>> > SqlConnection myConnection = new>> > SqlConnection("server=10.0.0.2;database=MyDatabase;Trusted_Connection=yes");>> > SqlDataAdapter myCommand = new SqlDataAdapter("select * from Authors",>> > myConnection);>> >>> > DataSet ds = new DataSet();>> > myCommand.Fill(ds, "Authors");>> >>> > MyDataGrid.DataSource=ds.Tables["Authors"].DefaultView;>> > MyDataGrid.DataBind();>> > any one has any idea whats wrong thanks>> > "Juan T. Llibre" wrote:>> >>> >> For SQL Server 2000 / ASP.NET 1.1 :>> >>>> >> http://samples.gotdotnet.com/quickstart/aspplus/>> >>>> >> For SQL Server 2005 / ASP.NET 2.0 :>> >>>> >>
 

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

Back
Top