Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 25th, 2007, 03:40 AM
Registered User
 
Join Date: Sep 2007
Posts: 6
Thanks: 0
Thanked 1 Time in 1 Post
Default connectivity with sql server 2005.

how can i connect my asp.net - C# form with sql server 2005 database?
 
Old September 25th, 2007, 04:00 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Well, as a beginner, you can try the code below which fetches some data into a dataset.

string strCon = @"Data Source=yourservername;" +
"Initial Catalog=Northwind;Integrated Security=SSPI";

string strSql="select * from customers";
SqlConnection con=new SqlConnection(strCon);
con.Open();

SqlDataAdapter dadapter=new SqlDataAdapter();
dadapter.SelectCommand=new SqlCommand(strSql,con);

DataSet dset=new DataSet();
dadapter.Fill(dset);

con.Close();


Regards
Mike





Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Server 2000 connectivity issue avixorld ASP.NET 2.0 Professional 8 July 25th, 2007 09:17 AM
SQL Server 2005 connectivity anita SQL Server 2005 3 September 20th, 2006 10:17 AM
connectivity of c++ to sql server 2000 nigam.samir C++ Programming 0 August 12th, 2006 08:01 AM
ASP.NET connectivity with SQL server shupi Classic ASP Databases 0 September 19th, 2005 07:09 AM
SQl Server Connectivity a_saravgi VB.NET 2002/2003 Basics 2 January 6th, 2005 12:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.