Current location: Hot Scripts Forums » Programming Languages » ASP.NET » ASP.NET Connection to MS SQL Server 2005 Express


ASP.NET Connection to MS SQL Server 2005 Express

Reply
  #1 (permalink)  
Old 12-12-08, 04:17 AM
cancer10 cancer10 is offline
Wannabe Coder
 
Join Date: Oct 2006
Location: India
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Question ASP.NET Connection to MS SQL Server 2005 Express

Hi Ppl,


I come from a PHP programming background, I also know classic asp 3 very well. Now, I wanna learn ASP.net, Last night I was going through an ASP.net Ebook, But the connection string given in that book had many lines of code and confusing too.

In PHP or classic asp, we had 1 or just 2 line of code for connecting to the DB (in VB and C#).

Can someone please tell me a connection code with a minimal line of code?

Also, Since I am from a PHP background, Plz suggest me which language should I use for ASP.net (VB or C#)?


Thanx
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 12-12-08, 01:23 PM
digioz's Avatar
digioz digioz is offline
Community VIP
 
Join Date: Oct 2003
Location: Chicago, IL
Posts: 2,167
Thanks: 3
Thanked 8 Times in 8 Posts
I made that same transition some 6 years ago. I recommend C# for PHP developers switching over.

Here is a Class I wrote for database connectivity, etc to make it easier:

http://digioznetportal.cvs.sourceforge.net/viewvc/digioznetportal/DigiOz%20.NET%20Portal/App_Code/clsMSSQL.cs?view=markup

And here is how to use it:

Code:
string lsSQL = "SELECT * FROM tblConfig";
clsData coDB = new clsData();
coDB.dbhost = "HOSTNAME";
coDB.dbname = "DATABASENAME";
coDB.dbuser = "USERNAME"
coDB.dbpass = "PASSWORD";
coDB.dbtype = "MSSQL";
coDB.openConnection();
coDB.QueryDBDataset(lsSQL);
loDT = coDB.ds.Tables[0];
...
coDB.closeConnection();
The class is part of a larger open source portal I am writing, so you may have remove the ": IData" from the class declaration.

Pete
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
2 Months Free Hosting -Windows 2003 | Cold Fusion MX | SQL Server | ASP.NET Gineey General Advertisements 0 01-11-06 06:31 AM
Search Engine Cloaker (Check out my SE crawls) absurdness General Advertisements 0 09-29-05 05:58 AM
SQL Server Connection in ASP.NET using VB.NET nsuresh_rasr ASP.NET 1 02-23-05 01:10 PM
change my field in this example sal21 ASP 3 07-14-03 03:49 AM


All times are GMT -5. The time now is 10:27 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.