borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2013 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Help with Crystal and ASP)Next Topic (Split text and image from word document) New Topic New Poll Post Reply
AndreaVB Forum : ASP.Net : SQL
Poster Message
CLIPER
Level: Big Cheese

Registered: 26-07-2005
Posts: 27

icon SQL

Hi,

When I first use .NET I get Started to Connect to my Databases and when I do, I finally found out that I need a Correction. So I hope to have a better answer in here. Thanks.

I use to Connect to my Database is

Dim Connect as Adodb.Connection
Set Connect = "Provider blah blah blah


I just need a question here...
When I query, I use this

dim rs as adodb.recordset
set rs = Connect.Execute("SELECT blah FROM Blah")

can I really use this in .NET? or it will only be available in Visual Basic? thanks in Advance..




Always,

Mark


____________________________
CLIPER

26-08-2005 at 06:36 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
TJ_01
Level: VB Lord


Registered: 24-08-2005
Posts: 317
icon Re: SQL

Hi clipper.

There are some parameters or syntax used in .NET that are not applicable in VB6 and vice versa. I used this sample code in connecting database using .NET.

' Create a connection string
Dim ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\\Northwind.mdb"
Dim sql As String = "SELECT CustomerId, CompanyName, ContactName From Customers"


____________________________
Im JAMES  

29-08-2005 at 03:31 AM
View Profile Send Email to User Show All Posts | Quote Reply
~Bean~
Level: VB Guru


Registered: 07-04-2003
Posts: 480
icon Re: SQL

.NET does not have a recordset object, at first I was like WTF but now that I have been working with .NET for a few months I don't miss it a bit. You can use old ASP code in a .NET project. but I recommend getting up to speed with how .NET ADO has changed (into ADO.NET......go figure...)

See  THIS LINK HERE



'Sample Data Access Using SQL Server
'(for other DB use OleDB)

'Before your class make sure you have...
Imports System.Data.SQLClient   'for SQL Server conn

'In your procedure/function...
Dim objConn As SqlConnection
'your connection string will be pretty much the same as before...
objConn = New SqlConnection(connection_string)
objConn.Open
Dim oCmd as New SqlCommand("SELECT id FROM tblTable", objConn)
oCmd.CommandType = CommandType.Text
Dim oReader as SqlDataReader
oReader = oCmd.ExecuteReader
While oReader.Read
    'do something with data
    myIDs = oReader.Item("id")
End While
oReader.Close
objConn.Close


This example shows looping thru a data reader. Although slower than the data reader, you should also check out the Dataset object in Help or look for some examples on that because it is just so dang useful....(binding to a datagrid)

____________________________
Eggheads unite! You have nothing to lose but your yolks.

03-09-2005 at 01:36 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
Bharathi
Level: Scholar

Registered: 11-04-2005
Posts: 31
icon Re: SQL

Hi,

regards
bhar



[Edited by Bharathi on 17-05-2013 at 12:46 PM GMT]

20-09-2005 at 06:17 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
AndreaVB Forum : ASP.Net : SQL
Previous Topic (Help with Crystal and ASP)Next Topic (Split text and image from word document) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2013 Andrea Tincaniborder