By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,676 Members | 1,669 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,676 IT Pros & Developers. It's quick & easy.

asp.net and sql server

P: n/a
how to connection sql server table with aspx like pulling data from table to
grid view.... simple example to start ....
thanks
May 31 '06 #1
Share this Question
Share on Google+
10 Replies


P: n/a
On "Microsoft Visual Studio 2005 Documentation" look for:

Visual Web Developer
Walkthrough: Basic Data Access in Web Pages

<Harvey Triana />
"amjad" <am***@discussions.microsoft.com> escribió en el mensaje
news:CF**********************************@microsof t.com...
how to connection sql server table with aspx like pulling data from table
to
grid view.... simple example to start ....
thanks

May 31 '06 #2

P: n/a
See if this helps and gets you started..

http://www.netomatix.com/DataGridSeries.aspx
"amjad" <am***@discussions.microsoft.com> wrote in message
news:CF**********************************@microsof t.com...
how to connection sql server table with aspx like pulling data from table
to
grid view.... simple example to start ....
thanks

May 31 '06 #3

P: n/a
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" <am***@discussions.microsoft.com> wrote in message
news:CF**********************************@microsof t.com...
how to connection sql server table with aspx like pulling data from table to
grid view.... simple example to start ....
thanks

May 31 '06 #4

P: n/a
I have used the link below and try to run the example
"http://samples.gotdotnet.com/quickstart/util/srcview.aspx?path=/quickstart/aspplus/samples/webforms/data/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" <am***@discussions.microsoft.com> wrote in message
news:CF**********************************@microsof t.com...
how to connection sql server table with aspx like pulling data from table to
grid view.... simple example to start ....
thanks


Jun 1 '06 #5

P: n/a
You haven't opened the connection anywhere.
amjad wrote:
I have used the link below and try to run the example
"http://samples.gotdotnet.com/quickstart/util/srcview.aspx?path=/quickstart/aspplus/samples/webforms/data/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" <am***@discussions.microsoft.com> wrote in message
news:CF**********************************@microsof t.com...
how to connection sql server table with aspx like pulling data from table to
grid view.... simple example to start ....
thanks


Jun 1 '06 #6

P: n/a
re:
but still got error my sqlserver is on ip 10.0.0.2
("server=10.0.0.2;database=MyDatabase;Trusted_Conn ection=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=usern ame;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;databa se=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" <am***@discussions.microsoft.com> wrote in message
news:80**********************************@microsof t.com...I have used the link below and try to run the example
"http://samples.gotdotnet.com/quickstart/util/srcview.aspx?path=/quickstart/aspplus/samples/webforms/data/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" <am***@discussions.microsoft.com> wrote in message
news:CF**********************************@microsof t.com...
> how to connection sql server table with aspx like pulling data from table to
> grid view.... simple example to start ....
> thanks


Jun 1 '06 #7

P: n/a
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_Conn ection=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=usern ame;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;databa se=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" <am***@discussions.microsoft.com> wrote in message
news:80**********************************@microsof t.com...
I have used the link below and try to run the example
"http://samples.gotdotnet.com/quickstart/util/srcview.aspx?path=/quickstart/aspplus/samples/webforms/data/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" <am***@discussions.microsoft.com> wrote in message
news:CF**********************************@microsof t.com...
> how to connection sql server table with aspx like pulling data from table to
> grid view.... simple example to start ....
> thanks


Jun 1 '06 #8

P: n/a
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" <am***@discussions.microsoft.com> wrote in message
news:FB**********************************@microsof t.com...
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_Conn ection=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=usern ame;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;databa se=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" <am***@discussions.microsoft.com> wrote in message
news:80**********************************@microsof t.com...
>I have used the link below and try to run the example
> "http://samples.gotdotnet.com/quickstart/util/srcview.aspx?path=/quickstart/aspplus/samples/webforms/data/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" <am***@discussions.microsoft.com> wrote in message
>> news:CF**********************************@microsof t.com...
>> > how to connection sql server table with aspx like pulling data from table to
>> > grid view.... simple example to start ....
>> > thanks
>>
>>
>>


Jun 1 '06 #9

P: n/a
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/d...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.sq l"
SQLCMD -E -i "C:\PathToTheDownloadedSampleDatabases\instnwnd.sq l"

SQL Server Management Studio is available at :
http://www.microsoft.com/downloads/d...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/d...laylang=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" <am***@discussions.microsoft.com> wrote in messagenews:FB**********************************@m icrosoft.com...> 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_Conn ection=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=usern ame;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;databa se=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" <am***@discussions.microsoft.com> wrote in message>> news:80**********************************@microsof t.com...>> >I have used the link below and try to run the example>> >"http://samples.gotdotnet.com/quickstart/util/srcview.aspx?path=/quickstart/aspplus/samples/webforms/data/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" <am***@discussions.microsoft.com> wrote in message>> >> news:CF**********************************@microsof t.com...>> >> > how to connection sql server table with aspx like pulling data from table to>> >> > grid view.... simple example to start ....>> >> > thanks>> >>>> >>>> >>>>>>>>

Jun 1 '06 #10

P: n/a
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" wrote:
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/d...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.sq l"
SQLCMD -E -i "C:\PathToTheDownloadedSampleDatabases\instnwnd.sq l"

SQL Server Management Studio is available at :
http://www.microsoft.com/downloads/d...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/d...laylang=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" <am***@discussions.microsoft.com> wrote in messagenews:FB**********************************@m icrosoft.com...> 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_Conn ection=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=usern ame;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;databa se=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" <am***@discussions.microsoft.com> wrote in message>> news:80**********************************@microsof t.com...>> >I have used the link below and try to run the example>>"http://samples.gotdotnet.com/quickstart/util/srcview.aspx?path=/quickstart/aspplus/samples/webforms/data/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" <am***@discussions.microsoft.com> wrote in message>> >> news:CF**********************************@microsof t.com...>> >> > how to connection sql server table with aspx like pulling data from table to>> >> > grid view.... simple example to start ....>> >> > thanks>> >>>> >>>> >>>>>>>>

Jun 1 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.