.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 25th, 2004, 09:56 PM
infamous-online infamous-online is offline
Moderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 404 infamous-online User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 24 m 44 sec
Reputation Power: 7
Connecting To An Sql Server using .Net Pages

well i've been away from the database designs of asp/.net and mssql, due to working with mostly php/mysql clients.

anyways, i've recently picked up my interest into the .net language and i am now trying to simply connect a .net page to an sql server 2000 database.

is there any books or tutorials out there that can help me get over this slight hump.

thanks in advance


will
__________________
Apache Expert

Reply With Quote
  #2  
Old November 29th, 2004, 07:08 AM
balaji_sp balaji_sp is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 4 balaji_sp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
There are two way to connect to database in asp.net they are

1) ADO.net

2) ADODB is the old way of connecting to database as same as asp



There are many types of connection few are

1) SqlConnection (this is only for SQL Server this will be faster because it is connection SQL Server directly)

2) OleDbConnection (this is for all database oracle,access,sql server and etc.)

3) OdbcConnection



Here I am using only SqlConnection



In Ado.net there are two type of retrieving the details from database



1) Using DataSet

2) Using Data Reader



1) Dataset it is the advanced way of using database.

In this u can maintain the relation and it is disconnected environment that means once you retrieved the data's form the database and fill in the dataset you can close the connection after you closed the connection also you can work with is data's. After changes are made you can open the connection and update the changes



Imports System.Data.SqlClient



Public Class Form1 Inherits System.Windows.Forms.Form

Dim SqlConn As SqlConnection

Dim SqlDA As SqlDataAdapter

Dim SQLDS As DataSet

Dim DRow As DataRow



Private Sub Form1_Load (ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load

SqlConn = new SqlConnection("connection String")

SqlDA = new SqlDataAdapter("SqlQuery",SqlConn)

SqlDA.Fill(DS,"Any Name for the Reference")



For Each DRow In ds.Tables ("Customer").Rows

ComboBox1.Items.Add (DRow("Customer_Name"))

Next

End Sub

End Class





2) Data Reader it will give the recordset as readonly and forward only.



Imports System.Data.SqlClient



Public Class Form1 Inherits System.Windows.Forms.Form

Dim SqlConn As SqlConnection

Dim SqlComm As SqlCommand

Dim SqlDR As SqlDataReader

Private Sub Form1_Load (ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load

SqlConn = new SqlConnection("connection String")

SqlConn.open()

SqlComm = new SqlCommand("SqlQuery",SqlConn)

SqlDR = Sqlcomm.ExecuteReader

While (SqlDR.Read)

ComboBox1.Items.Add(SqlDR("Col_Name"))

End While



End Sub



End Class

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > Connecting To An Sql Server using .Net Pages


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT