Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET 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 9th, 2005, 06:37 PM
Registered User
Join Date: Sep 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Database Connection

How can i write code using ADO.Net for sql database connection like ADO. In ADO just 3 line u can access the database, but ADO.Net, more than 3 lines of coding we required. please let me the simplest method to access the database.

Old September 9th, 2005, 11:03 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik

Drog the SqlConnection from Data Tab & drop it to ur form. then set the connection in vistual mode.

I think u can NOT find the easy way from this!

Hovik Melkomian.
Old September 25th, 2005, 12:27 PM
aty aty is offline
Registered User
Join Date: Sep 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to aty

you can write the Global.asax.vb
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)Application.Contents("conn") = ("Data Source=IP;Initial Catalog=DataBaseName;uid=username;pwd=password")
Application.Contents("conn") = ("Data Source=Your instance name;Initial Catalog=database name;Integrated security=true")
End Sub

and you can write forms button1.Click
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim con As New SqlClient.SqlConnection
        con = New SqlClient.SqlConnection(Application("conn"))
end sub

Old September 26th, 2005, 02:52 AM
Registered User
Join Date: Sep 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts

Hi kulasekar,

There is no Detail where you want to access.
It will diff for windows based form and web based form.

You can do in Three ways.
1. Create a link in server explorer for the DataTable.
   And drag and drop the table you can get the records from dataset.
2. Open Data in design mode Drag the sqlDataAdaptor complete the Wizard with your Sql Quiery and Datatable.
   Right Click the DataAdaptor Create a Dataset and Use it.
3. in Runtime.
   Create A conn Obj set conn String 'conn
   Create a Command Obj set Sql Quiery. 'cmd
   Create a DataReader Obj set command Obj.ExcuteReader. 'dr
   While dr.Read
   End While

I hope this may help to you.

Thanks and Regards

Difficult can be done immediately. But Impossible will take some more time.
Old October 5th, 2005, 02:54 AM
Authorized User
Join Date: Aug 2003
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts

Oh My God! I don't think that connect to database make you can cry!

he he

Old March 27th, 2006, 05:25 AM
Registered User
Join Date: Feb 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts

You can connect the database by using a wizard. Using the wizard you have drag a SqlConnection from tool to the form and follow instructions.
In case you want to connect at runtime then you have to use –

        Dim myConnectString As String = "Provider…………"
        Dim myConnection As New SqlClient.SqlConnection(myConnectString)

Similar Threads
Thread Thread Starter Forum Replies Last Post
Database Connection to Access Database reachsevar ASP.NET 2.0 Basics 1 November 28th, 2007 08:56 AM
Database Connection oneillg PHP Databases 1 October 17th, 2007 04:48 PM
Database Connection kapi.goel SQL Language 2 February 14th, 2006 07:01 PM
database connection Nitin_sharma Classic ASP Databases 1 February 8th, 2005 10:23 AM

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