473,410 Members | 1,889 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,410 software developers and data experts.

Trying to write ADO code in VB.Net environment

Hi,
I am upgrading my database componenet from VB6.0 to VB.net but would like to use ADO for database operation. Am trying to retrieve no of tables in a database using connection.openschema method of ADODB. It works fine in VB6.0 but blows of in VB.net. The code looks like
rsReadOnly = New ADODB.Recordset
rsReadOnly = goConnection.OpenSchema(ADODB.SchemaEnum.adSchemaT ables, New Object() {Nothing, Nothing, Nothing, "TABLE"})
The Error message is :System.NullReferenceException - Object variable or With block variable not set.

Very Urgent........
--
System Analyst
Nov 20 '05 #1
1 3604
The following code will put all the table information in a datagrid and
indicate the number of tables of all table types.

'need reference to ADODB
Try
Dim Conn As New ADODB.Connection
Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & Application.StartupPath & "\test.mdb"
Conn.Open()
Dim rs As New ADODB.Recordset
rs = Conn.OpenSchema(ADODB.SchemaEnum.adSchemaTables)
Dim MyTable As New DataTable
Dim da As New Data.OleDb.OleDbDataAdapter
da.Fill(MyTable, rs)
Me.DataGrid1.DataSource = MyTable
Me.DataGrid1.Refresh()
MsgBox(MyTable.Rows.Count.ToString)
Catch ex As Exception
MsgBox(ex.Message)
End Try
"Lokanath" <it*******@yahoo.com> wrote in message
news:44**********************************@microsof t.com...
Hi,
I am upgrading my database componenet from VB6.0 to VB.net but would like to use ADO for database operation. Am trying to retrieve no of tables in a
database using connection.openschema method of ADODB. It works fine in VB6.0
but blows of in VB.net. The code looks like rsReadOnly = New ADODB.Recordset
rsReadOnly = goConnection.OpenSchema(ADODB.SchemaEnum.adSchemaT ables, New Object()
{Nothing, Nothing, Nothing, "TABLE"}) The Error message is :System.NullReferenceException - Object variable or With block variable not set.
Very Urgent........
--
System Analyst

Nov 20 '05 #2

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

Similar topics

8
by: Rich Grise | last post by:
I think I've finally found a tutorial that can get me started: http://www.zib.de/Visual/people/mueller/Course/Tutorial/tutorial.html and I've been lurking for awhile as well. What happened is,...
13
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be...
1
by: cnu | last post by:
My program generates a log file for every event that happens in the program. So, I open the file and keep it open till the end. This is how I open the file for writing: <CODE> public...
16
by: Andrew Baker | last post by:
I am trying to write a function which provides my users with a file filter. The filter used to work just using the VB "Like" comparision, but I can't find the equivilant in C#. I looked at...
1
by: kCura | last post by:
First off, I'm sorry if this isn't the write thread to post this message but I couldn't find one dedicated to System.Drawing. I'm developing an intranet application in VB.NET that uses a Hosted...
5
by: Eric Cadwell | last post by:
Is there a faster way to write the last 100K of a large file? This code takes almost two minutes to run on my machine. int buffer = 100000; int length = 2000000000; string file =...
2
by: Jim | last post by:
Hello everyone, This is my first time posting to a Usenet group, so please excuse any Netiquette errors I may have in my post. I have used ASP.NET before using C#, but never VB, so I'm trying...
3
by: Daniel Jeffrey | last post by:
Hello, I have been searching for hours and can find no help on this. I need to programmatically write a UDL file for a only Delphi Application to use (my program is a launcher). I was able...
5
by: walterbyrd | last post by:
I don't know much php either, but running a php app seems straight forward enough. Python seems to always use some sort of development environment vs production environment scheme. For...
3
by: Max58kl | last post by:
Trying to access data and print it to the screen using Perl Builders I/O Window -------------------------------------------------------------------------------- Hi I am using a program called...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.