Coding ADO in VB.Net environment

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.adSchemaTables, New Object() {Nothing, Nothing, Nothing, "TABLE"})
The Error message is :System.NullReferenceException - Object variable or With block variable not set.

Very Urgent........
 
Sure you can. You won't be happy in the end (and neither will your
customer), but it can be done. Most of ADO classic works in under .NET via
COM interop. However, I think you'll find a dozen things like you've found
that make ADO classic tough to use in .NET. Part of the problem is that
Nothing is not the same in .NET. ADOc makes heavy use of variants and .NET
does not support these (it uses type Object instead). I list more
incompatibilities in my book.

Most folks take VB6 ADOc code tasks and converts then individually to
ADO.NET.
What are you trying to do here?


--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

Lokanath said:
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.adSchemaTables, New Object()
{Nothing, Nothing, Nothing, "TABLE"})
The Error message is :System.NullReferenceException - Object
variable or With block variable not set.
 
Hi William,
I am Basically writing a dll in VB.Net environment but the Data retrieval part will be written in ADO not ADO.Net. As per client's requirement. The DLL/COM component written in VB6.0 using ADO works very fine. But i am struggling a lot when i try to use same or modified code in .net. Most of the places it blows of. If u can tell me any good site and any link which can help me in developing it , will be very helpfull.
The latest problem i am facing is
in VB6.0 "IsNull(rsReadOnly!TABLE_SCHEMA)" , once i changed it to vb.net like this
" IsNothing(rsReadOnly.Fields("TABLE_SCHEMA")) " . It does not gives me required output.

Thanks
Lokanath
 
I wish I could help more, but as I said, we don't have a lot of people doing
this--for good reason. The approach is fraught with problems (as you have
found).

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

"Coding ADO in VB.Net environment" <Coding ADO in VB.Net
(e-mail address removed)> wrote in message
Hi William,
I am Basically writing a dll in VB.Net environment but the Data retrieval
part will be written in ADO not ADO.Net. As per client's requirement. The
DLL/COM component written in VB6.0 using ADO works very fine. But i am
struggling a lot when i try to use same or modified code in .net. Most of
the places it blows of. If u can tell me any good site and any link which
can help me in developing it , will be very helpfull.
 
Back
Top