Answered by:
No ADODB in VB express edition 2008 ?

Question
-
Hi,
I am learning Visual Basic, using Visual Basic Express Edition 2008.
I was trying to code a database sample using ADODB.
Looks like the object(i assume predefined) ADODB is not recognized by the IDE.
Look at this code snippet :
Dim MyConnObj As New ADODB.Connection 'ADODB Connection Object Dim myRecSet As New ADODB.Recordset 'Recordset Object
As soon as i type these lines, i get 2 red marks, errors. The error pane shows this message - "Type ADODB.Connection is not defined"
...
Why ?
Any help is appreciated.
Thanks in advance.Monday, December 1, 2008 10:29 PM
Answers
-
All data related objects now reside in the System.Data namespace. For what you would have used ADODB for, now use System.Data.OleDb.OleDbConnection.
ADO is now ADO.Net - since you seem to be coming from classic ADO you will NEED to look up the differences in the MSDN documentation or these forums. There are many articles/tutorials about ADO.Net - you would be VERY well served to start with one of these. Check out the samples available from the VB learning center here at MSDN.
There is no such thing as a "Recordset" anymore - you will have a lot of trouble if you don't first look into the differneces between ADO and ADO.Net.
Reed Kimble - "When you do things right, people won't be sure you've done anything at all"- Marked as answer by Martin Xie - MSFT Monday, December 8, 2008 8:37 AM
Monday, December 1, 2008 10:53 PMModerator -
Read this book(download it by Entire book) about the more introduction about ADO and ADO.NET. The chapter14 and chapter20 give the whole introduction.
Please remember to mark the replies as answers if they help and unmark them if they provide no help.- Proposed as answer by konikula Monday, December 8, 2008 9:21 AM
- Marked as answer by Reed KimbleMVP, Moderator Monday, December 8, 2008 4:02 PM
Thursday, December 4, 2008 6:36 AMModerator -
stunshiva said:
I was trying to code a database sample using ADODB.
Looks like the object(i assume predefined) ADODB is not recognized by the IDE.
Look at this code snippet :
Dim MyConnObj As New ADODB.Connection 'ADODB Connection Object
Dim myRecSet As New ADODB.Recordset 'Recordset Object
Hi stunshiva,
Welcome to MSDN forums!
In .NET, we recommend using ADO.NET service which is more convenient and efficient than the old ADO service.
System.Data.OleDb namespace is used for MS Access database.
System.Data.SqlClient namespace is used for SQL Server database.
Code sample: Display MS Access database table records on DataGridViewImports System.Data.OleDb Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=D:\myDB.mdb") Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM Table1", con) con.Open() Dim myDA As OleDbDataAdapter = New OleDbDataAdapter(cmd) Dim myDataSet As DataSet = New DataSet() myDA.Fill(myDataSet, "MyTable") DataGridView1.DataSource = myDataSet.Tables("MyTable").DefaultView con.Close() con = Nothing End Sub End Class
Code sample: Display SQL Server database table records on DataGridViewImports System.Data.SqlClient Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim con As SqlConnection = New SqlConnection("Data Source=.;Integrated Security=True;AttachDbFilename=D:\SqlDatabase.mdf") Dim cmd As SqlCommand = New SqlCommand("SELECT * FROM AccessPage", con) con.Open() Dim myDA As SqlDataAdapter = New SqlDataAdapter(cmd) Dim myDataSet As DataSet = New DataSet() myDA.Fill(myDataSet, "MyTable") DataGridView1.DataSource = myDataSet.Tables("MyTable").DefaultView con.Close() con = Nothing End Sub End Class Further tutorial: Four methods to make simple Data Access application(Next, Previous, First, Last, Update, Delete, Insert, Save) in VB.NET.
http://social.msdn.microsoft.com/Forums/en/vbgeneral/thread/55170a2e-b4f8-46eb-8b6f-8040db334a39/
Additionally, if you have to use classic/tradtional ADO service in VB.NET, you need to Add Reference this COM component "Microsoft ActiveX Data Object Library" to your project.Example: Using ADODB Services in .NET WinForms Applications in VB.NET
http://www.vbdotnetheaven.com/UploadFile/ptailor/ADODBServices04082005081324AM/ADODBServices.aspx
This article walks you through the usage of ADODB services in .NET application using VB.NET language. The example details the data access using ADODB, fetching recordset, filling ADO.NET dataset from the recordset and binding the same to datagrid for user display.
Best regards,
Martin Xie- Proposed as answer by konikula Monday, December 8, 2008 9:21 AM
- Marked as answer by Reed KimbleMVP, Moderator Monday, December 8, 2008 4:02 PM
- Edited by Martin Xie - MSFT Tuesday, December 9, 2008 7:55 AM Recommend using ADO.NET service (instead of the old ADO) in VB.NET.
Monday, December 8, 2008 8:53 AM
All replies
-
Hi,
I am learning Visual Basic, using Visual Basic Express Edition 2008.
I was trying to code a database sample using ADODB.
Looks like the object(i assume predefined) ADODB is not recognized by the IDE.
Look at this code snippet :
Dim MyConnObj As New ADODB.Connection 'ADODB Connection Object Dim myRecSet As New ADODB.Recordset 'Recordset Object
As soon as i type these lines, i get 2 red marks, errors. The error pane shows this message - "Type ADODB.Connection is not defined"
...
Why ?
(Usually code completions will be available for each object when we type the dot ".", eg "ADODB." ... code completion wasnt available too )
Any help is appreciated.
Thanks in advance.- Merged by Xingwei Hu Monday, December 8, 2008 5:50 AM the same question
Monday, December 1, 2008 10:25 PM -
All data related objects now reside in the System.Data namespace. For what you would have used ADODB for, now use System.Data.OleDb.OleDbConnection.
ADO is now ADO.Net - since you seem to be coming from classic ADO you will NEED to look up the differences in the MSDN documentation or these forums. There are many articles/tutorials about ADO.Net - you would be VERY well served to start with one of these. Check out the samples available from the VB learning center here at MSDN.
There is no such thing as a "Recordset" anymore - you will have a lot of trouble if you don't first look into the differneces between ADO and ADO.Net.
Reed Kimble - "When you do things right, people won't be sure you've done anything at all"- Marked as answer by Martin Xie - MSFT Monday, December 8, 2008 8:37 AM
Monday, December 1, 2008 10:53 PMModerator -
Reed Kimble said:This is correct: there is zero relation between ADO and ADO.NET except in name. It's a tough hill to climb, just as ADO was quite a tough hill, but once you figure out the coding patterns it really isn't too bad.
...
...
There is no such thing as a "Recordset" anymore - you will have a lot of trouble if you don't first look into the differneces between ADO and ADO.Net.
Stephen J WhiteleyTuesday, December 2, 2008 11:45 AMModerator -
Read this book(download it by Entire book) about the more introduction about ADO and ADO.NET. The chapter14 and chapter20 give the whole introduction.
Please remember to mark the replies as answers if they help and unmark them if they provide no help.- Proposed as answer by konikula Monday, December 8, 2008 9:21 AM
- Marked as answer by Reed KimbleMVP, Moderator Monday, December 8, 2008 4:02 PM
Thursday, December 4, 2008 6:36 AMModerator -
stunshiva said:
I was trying to code a database sample using ADODB.
Looks like the object(i assume predefined) ADODB is not recognized by the IDE.
Look at this code snippet :
Dim MyConnObj As New ADODB.Connection 'ADODB Connection Object
Dim myRecSet As New ADODB.Recordset 'Recordset Object
Hi stunshiva,
Welcome to MSDN forums!
In .NET, we recommend using ADO.NET service which is more convenient and efficient than the old ADO service.
System.Data.OleDb namespace is used for MS Access database.
System.Data.SqlClient namespace is used for SQL Server database.
Code sample: Display MS Access database table records on DataGridViewImports System.Data.OleDb Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=D:\myDB.mdb") Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM Table1", con) con.Open() Dim myDA As OleDbDataAdapter = New OleDbDataAdapter(cmd) Dim myDataSet As DataSet = New DataSet() myDA.Fill(myDataSet, "MyTable") DataGridView1.DataSource = myDataSet.Tables("MyTable").DefaultView con.Close() con = Nothing End Sub End Class
Code sample: Display SQL Server database table records on DataGridViewImports System.Data.SqlClient Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim con As SqlConnection = New SqlConnection("Data Source=.;Integrated Security=True;AttachDbFilename=D:\SqlDatabase.mdf") Dim cmd As SqlCommand = New SqlCommand("SELECT * FROM AccessPage", con) con.Open() Dim myDA As SqlDataAdapter = New SqlDataAdapter(cmd) Dim myDataSet As DataSet = New DataSet() myDA.Fill(myDataSet, "MyTable") DataGridView1.DataSource = myDataSet.Tables("MyTable").DefaultView con.Close() con = Nothing End Sub End Class Further tutorial: Four methods to make simple Data Access application(Next, Previous, First, Last, Update, Delete, Insert, Save) in VB.NET.
http://social.msdn.microsoft.com/Forums/en/vbgeneral/thread/55170a2e-b4f8-46eb-8b6f-8040db334a39/
Additionally, if you have to use classic/tradtional ADO service in VB.NET, you need to Add Reference this COM component "Microsoft ActiveX Data Object Library" to your project.Example: Using ADODB Services in .NET WinForms Applications in VB.NET
http://www.vbdotnetheaven.com/UploadFile/ptailor/ADODBServices04082005081324AM/ADODBServices.aspx
This article walks you through the usage of ADODB services in .NET application using VB.NET language. The example details the data access using ADODB, fetching recordset, filling ADO.NET dataset from the recordset and binding the same to datagrid for user display.
Best regards,
Martin Xie- Proposed as answer by konikula Monday, December 8, 2008 9:21 AM
- Marked as answer by Reed KimbleMVP, Moderator Monday, December 8, 2008 4:02 PM
- Edited by Martin Xie - MSFT Tuesday, December 9, 2008 7:55 AM Recommend using ADO.NET service (instead of the old ADO) in VB.NET.
Monday, December 8, 2008 8:53 AM -
Also, are you sure to start just with ADO? I would guess it is much easier to start with OleDB or MySQL... for me ADO seems like return to iceage ;)
Posting you abusive right now, and all of your posts!Monday, December 8, 2008 9:26 AM -
Um, check also my tutorial ;)
http://www.developerfusion.com/article/7869/vbnet-and-ms-access/
best wishes, MaTT
Posting you abusive right now, and all of your posts!Monday, December 8, 2008 9:32 AM -
Oh Martin!
You said: "In VB.NET, to use classic/tradtional ADO service, you need to Add Reference this COM component "Microsoft ActiveX Data Object Library" to your project."
I try to keep that information secret!! hahahaha
It is like when you are being taught complex math - the teacher makes you do it the hard way until you get it, then shows you a shortcut that makes it easy... In this case, if the user knows they can go back and use the old ADO way of data access, they are likely to never learn to do it the new way! It is better (in my opinion) to say "You can't do it the old way - period", until they learn to do it the new way. Once they understand ADO.Net, then you can say "Oh, by the way, I lied - you can do it the old way; but it is only meant for converting old projects, not creating new ones".
That's my $0.02 any way!
Reed Kimble - "When you do things right, people won't be sure you've done anything at all"Monday, December 8, 2008 4:00 PMModerator -
Oh Reed,
Thank you for your kindly reminding!
Your are very considerate.
I have refined my previous post.
You are definitely an excellent teacher.Tuesday, December 9, 2008 8:00 AM