473,386 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

ADO example

JR
Hi,

I have always worked with DAO in VB6. Now I want to change to dotnet and
ado.

In general I don't have problems with dotnet(2003) but I need a example for
a simple database (ex: 2 fields: name and adres)

1. making the database
2. Making a table
3. Making a index
4. Making a relation

with info lines
Who can help me


Nov 21 '05 #1
6 1177
I found this one too:

Its a simple address book database using ADO:

http://www.planet-source-code.com/vb...=337&lngWId=10

"JR" wrote:
Hi,

I have always worked with DAO in VB6. Now I want to change to dotnet and
ado.

In general I don't have problems with dotnet(2003) but I need a example for
a simple database (ex: 2 fields: name and adres)

1. making the database
2. Making a table
3. Making a index
4. Making a relation

with info lines
Who can help me


Nov 21 '05 #3
JR,

Beneath a sample. I changed a little bit an older sample from me.
This uses ADO for the creating of the Access database (what is not possible
using ADONET) and for the rest ADONET. The samples I have seen (not mine)
use only ADO for this kind of solutions.

The questions about making a table etc. you have in my opinion to explain,
because I have seen this can confuse. Do you mean a database datatable or a
dataset datatable in this?

Where for creating a database datatable relation etc. you would have to use
classic ADO again.

I hope this helps,

Cor

set a reference to COM adox ext 2.x for dll and security
\\\
Public Class Main
Public Shared Sub Main()
Dim catNewDB As New ADOX.Catalog
Dim fi As New IO.FileInfo("c:\db1.mdb")
If fi.Exists Then
If MessageBox.Show("Delete?", "Existing File db1.mdb", _
MessageBoxButtons.YesNo) = DialogResult.Yes Then
fi.Delete()
Else
Exit Sub
End If
End If
catNewDB.Create("Provider=Microsoft.Jet.OLEDB.4.0; " & "Data
Source=C:\db1.mdb")
'To make tables we use Adonet
Dim conn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLED B.4.0;" &
_
" Data Source=C:\db1.mdb;User Id=admin;Password=;")
Dim cmd As New OleDb.OleDbCommand("CREATE TABLE persons ( " & _
"AutoId int identity ," & _
"Id int NOT NULL," & _
"Name NVarchar(50)," & _
"BirthDate datetime," & _
"IdCountry int," & _
"CONSTRAINT [pk_AutoId] PRIMARY KEY (AutoId)) ", conn)
conn.Open()
Try
cmd.ExecuteNonQuery()
Catch ex As OleDb.OleDbException
MessageBox.Show(ex.Message, "OleDbException")
Exit Sub
Catch ex As Exception
MessageBox.Show(ex.Message, "GeneralException")
Exit Sub
End Try
conn.Close()
End Sub
End Class
////
Nov 21 '05 #4
JR
Pleace Help

"JR" <XX***@xx.xx> schreef in bericht
news:PW*********************@phobos.telenet-ops.be...
Hi,

I have always worked with DAO in VB6. Now I want to change to dotnet and
ado.

In general I don't have problems with dotnet(2003) but I need a example
for
a simple database (ex: 2 fields: name and adres)

1. making the database
2. Making a table
3. Making a index
4. Making a relation

with info lines
Who can help me

Nov 21 '05 #5
JR
thanks all

Jan
"Cor Ligthert" <no************@planet.nl> schreef in bericht
news:%2****************@TK2MSFTNGP10.phx.gbl...
JR,

Beneath a sample. I changed a little bit an older sample from me.
This uses ADO for the creating of the Access database (what is not
possible using ADONET) and for the rest ADONET. The samples I have seen
(not mine) use only ADO for this kind of solutions.

The questions about making a table etc. you have in my opinion to explain,
because I have seen this can confuse. Do you mean a database datatable or
a dataset datatable in this?

Where for creating a database datatable relation etc. you would have to
use classic ADO again.

I hope this helps,

Cor

set a reference to COM adox ext 2.x for dll and security
\\\
Public Class Main
Public Shared Sub Main()
Dim catNewDB As New ADOX.Catalog
Dim fi As New IO.FileInfo("c:\db1.mdb")
If fi.Exists Then
If MessageBox.Show("Delete?", "Existing File db1.mdb", _
MessageBoxButtons.YesNo) = DialogResult.Yes Then
fi.Delete()
Else
Exit Sub
End If
End If
catNewDB.Create("Provider=Microsoft.Jet.OLEDB.4.0; " & "Data
Source=C:\db1.mdb")
'To make tables we use Adonet
Dim conn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLED B.4.0;"
& _
" Data Source=C:\db1.mdb;User Id=admin;Password=;")
Dim cmd As New OleDb.OleDbCommand("CREATE TABLE persons ( " & _
"AutoId int identity ," & _
"Id int NOT NULL," & _
"Name NVarchar(50)," & _
"BirthDate datetime," & _
"IdCountry int," & _
"CONSTRAINT [pk_AutoId] PRIMARY KEY (AutoId)) ", conn)
conn.Open()
Try
cmd.ExecuteNonQuery()
Catch ex As OleDb.OleDbException
MessageBox.Show(ex.Message, "OleDbException")
Exit Sub
Catch ex As Exception
MessageBox.Show(ex.Message, "GeneralException")
Exit Sub
End Try
conn.Close()
End Sub
End Class
////

Nov 21 '05 #6
JR
thanks all

Jan
"Cor Ligthert" <no************@planet.nl> schreef in bericht
news:%2****************@TK2MSFTNGP10.phx.gbl...
JR,

Beneath a sample. I changed a little bit an older sample from me.
This uses ADO for the creating of the Access database (what is not
possible using ADONET) and for the rest ADONET. The samples I have seen
(not mine) use only ADO for this kind of solutions.

The questions about making a table etc. you have in my opinion to explain,
because I have seen this can confuse. Do you mean a database datatable or
a dataset datatable in this?

Where for creating a database datatable relation etc. you would have to
use classic ADO again.

I hope this helps,

Cor

set a reference to COM adox ext 2.x for dll and security
\\\
Public Class Main
Public Shared Sub Main()
Dim catNewDB As New ADOX.Catalog
Dim fi As New IO.FileInfo("c:\db1.mdb")
If fi.Exists Then
If MessageBox.Show("Delete?", "Existing File db1.mdb", _
MessageBoxButtons.YesNo) = DialogResult.Yes Then
fi.Delete()
Else
Exit Sub
End If
End If
catNewDB.Create("Provider=Microsoft.Jet.OLEDB.4.0; " & "Data
Source=C:\db1.mdb")
'To make tables we use Adonet
Dim conn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLED B.4.0;"
& _
" Data Source=C:\db1.mdb;User Id=admin;Password=;")
Dim cmd As New OleDb.OleDbCommand("CREATE TABLE persons ( " & _
"AutoId int identity ," & _
"Id int NOT NULL," & _
"Name NVarchar(50)," & _
"BirthDate datetime," & _
"IdCountry int," & _
"CONSTRAINT [pk_AutoId] PRIMARY KEY (AutoId)) ", conn)
conn.Open()
Try
cmd.ExecuteNonQuery()
Catch ex As OleDb.OleDbException
MessageBox.Show(ex.Message, "OleDbException")
Exit Sub
Catch ex As Exception
MessageBox.Show(ex.Message, "GeneralException")
Exit Sub
End Try
conn.Close()
End Sub
End Class
////

Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Michael Foord | last post by:
#!/usr/bin/python -u # 15-09-04 # v1.0.0 # auth_example.py # A simple script manually demonstrating basic authentication. # Copyright Michael Foord # Free to use, modify and relicense. #...
6
by: Ville Vainio | last post by:
Just posting this for the sake of google: Like everyone else, I figured it's time to start using the 'logging' module. I typically want to dump "info" level (and up) log information to...
5
by: relaxedrob | last post by:
Hi All! I ran the following w3c example through my WSDL parser (SOA Editor from Cape Clear): http://www.w3.org/TR/wsdl#_rpcexample It told me that there were a bunch of erros about no...
1
by: Bo Xu | last post by:
Object of Combination By Bo Xu Introduction A combination of n things, taken s at a time, often referred as an s-combination out of n, is a way to select a subset of size s from a given set of...
25
by: Xah Lee | last post by:
Python Doc Problem Example: gzip Xah Lee, 20050831 Today i need to use Python to compress/decompress gzip files. Since i've read the official Python tutorial 8 months ago, have spent 30...
11
by: ajikoe | last post by:
Hello, I used Visual C# Standard Edition. I want to comment my program using xml commentary method, I don't know why if I use value and example tag, it is not working / showed in the html...
6
by: cj | last post by:
Lets just take this example I'm looking at now. I'm looking at the help screen titled .NET Framework Class Library FolderBrowserDialog Class . It gives an example at the bottom that begins with:...
8
by: Scott M. | last post by:
Where will code that is preceded with: /// <example> /// some comments /// </example> actually show up? I can see my <summaryand <remarkscode showing up in the code comment pages and in...
25
by: meltedown | last post by:
This is supposed ot be an example: http://www.ajaxtutorial.net/index.php/2006/11/30/simple-ajax-using-prototype-part-2/ It says : This example is probably the simplest example you will ever...
6
by: Guy Macon | last post by:
While I agree with the sentiment, the oringinal title on this thread ("OT: Specially for , why you should always use example.com for obfuscating domains") is wrong. There are other reserved domain...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.