borderAndreaVB free resources for Visual Basic developersborder

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

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

Print This Topic
Previous Topic (vb.net query)Next Topic (Can somebody help me convert this VB.NET code to VB6) New Topic New Poll Post Reply
AndreaVB Forum : VB.Net : Typed Dataset
Poster Message
Chris_871
Level: Master


Registered: 30-11-2002
Posts: 106

icon Typed Dataset

Dear Friends

How to create typed dataset in vb.net through coding.? and how to use locks while updation?

By
Chris



06-01-2004 at 10:32 AM
View Profile Send Email to User Show All Posts | Quote Reply
MacD
Level: Big Cheese

Registered: 06-01-2004
Posts: 19
icon Re: Typed Dataset

Hi papa.

What you need to use is the Commandbuilder, DataAdapter and of course the Query Statement that will make the dataset typed to the schema that you desire.

See the below example:

1. CONNECTING TO A DATABASE USING ODBC

Dim conString as String = "<CONECTION STRING VALUE>"

Dim myDS as DataSet

Dim myDA As OdbcDataAdapter
Dim ODBCCB As OdbcCommandBuilder

Dim ObdcConnection1 As New OdbcConnection(conString)

myDs = New DataSet

ObdCConnection1.Open

myDA = New OdbcDataAdapter("SELECT * FROM <TABLENAME>", ObdCConnection1)

SqlCB = New OdbcCommandBuilder(myDA)

myDA.FillSchema(myDS, "<TABLE NAME>")
.
.
.
.
.

ObdcConnection1.Close

2. CONNECTING TO AN SQL DATABASE CODE

Dim conString as String = "<CONECTION STRING VALUE>"

Dim myDS as DataSet

Dim myDA As SQLDataAdapter
Dim SqlCB As SQLCommandBuilder

Dim sqlConnection1 As New sqlConnection(conString)

myDs = New DataSet

sqlConnection1.Open

myDA = New sqlDataAdapter("SELECT * FROM <TABLENAME>", sqlConnection1)

SqlCB = New SqlCommandBuilder(myDA)

myDA.FillSchema(myDS, "<TABLE NAME>")
.
.
.
.
.

sqlConnection1.Close

3. CONNECTING TO A DATABASE USING OLEDB

Dim conString as String = "<CONECTION STRING VALUE>"

Dim myDS as DataSet

Dim myDA As OLEDbDataAdapter
Dim OLEDbCB As OLEDbCommandBuilder

Dim OLEDbConnection1 As New OLEDbConnection(conString)

myDs = New DataSet

OLEDbConnection1.Open

myDA = New OLEDbDataAdapter("SELECT * FROM <TABLENAME>", OLEDbConnection1)

OLEDbCB = New OLEDbCommandBuilder(myDA)

myDA.FillSchema(myDS, "<TABLE NAME>")
.
.
.
.
.

OLEDbConnection1.Close

I hope this will assist you.

Bye papa,




07-01-2004 at 07:33 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB.Net : Typed Dataset
Previous Topic (vb.net query)Next Topic (Can somebody help me convert this VB.NET code to VB6) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

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