Coding ADO in VB.Net environment

dotnet framework

    Next

  • 1. MS SQL SERVER LEFT OUTER JOIN query
    In MS sql Server I'm doing left Outer Join from say Table1 to Table2, I'm only selecting FK column of Table2 say "Table2.relFkCol", If there are no matching records in Table2 I'm getting Null for "Table2.relFkCol", and for matching records I get positive Integer value. I want to write query such that I get Boolean column, instead of Null or Positive Value. my present query is like this SELECT Project.*,ISNULL(Job.projectId, 0) AS jobTicketCreated FROM Project LEFT OUTER JOIN Job ON Project.projectId = Job.projectId Please can anybody help me here. thanks
  • 2. view to dataset
    I have a dataview with few rows. My requirement is that I have to transfer the rows in the view to my table in the dataset and bind the dataset to the datagrid. How can I do move the rowsin my dataviewit? thanks in advance, vijaya
  • 3. Mismatch between dataview rowfilter and oracle where clause results
    Hi All, I am using "dataView.RowFilter" method to filter the values in my .NET 1.0 C# web application. There is a Oracle 8i Database with a table "Operation" in which we have a field OperationCode( varchar2) with the following values : a1, a2, a3, 20, 21, 23, JEN I am using DataView.RowFilter method 'CaseSensitivity' property of underlying datatable is set to true. 1) Setting dataviews's rowfilter Criteria as OPERATIONCODE < 'a101' returns 4 records a1, 20,21, 23 in the application. 2) TOAD/Oracle sqlplus Returns 5 records a1, 20, 21, 23, JEN sqlplus returns the same a1, 20, 21, 23, JEN SO Oracle consider A-Z to be less than a-z whereas .net dataview rowfilter doesnt seem to do so So the filtering values are different from the values which we get by querying the database. Is there a way to get the same values from my dataviews row filter. We have tried the same thing in framework 1.1 also and with all types of providers for oracle like OLEDB ODBC and Microsoft and Oracle Data Providers but all give the same results. Any thoughts on this.... Thanks in advance. Regards, Sriram

Coding ADO in VB.Net environment

Postby TG9rYW5hdGg » Thu, 05 Aug 2004 05:25:02 GMT

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........
-- 
System Analyst

Re: Coding ADO in VB.Net environment

Postby William (Bill)Vaughn » Thu, 05 Aug 2004 05:37:54 GMT

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.
__________________________________





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
goConnection.OpenSchema(ADODB.SchemaEnum.adSchemaTables, New Object()
{Nothing, Nothing, Nothing, "TABLE"})
variable or With block variable not set.



Re: Coding ADO in VB.Net environment

Postby Q29kaW5nIEFETyBpbiBWQi5OZXQgZW52aXJvbm1lbnQ » Thu, 05 Aug 2004 08:43:02 GMT

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









Re: Coding ADO in VB.Net environment

Postby William (Bill)Vaughn » Thu, 05 Aug 2004 12:15:56 GMT

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




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.
like this
required output.

via
found
.NET
rights.



like
a
VB6.0



Similar Threads:

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

Very Urgent........
-- 
System Analyst

2.Converting code ADO VBA to ADO net VB.net

I wish to access sql data in a vb net (vs2008) program and have an ADO VBA 
(in excel) routine that was used to read the files in excel.  The code (in 
excel VBA) is:

Sub PriceExtract()
' Create a connection object.
Dim cnLevel As ADODB.Connection
Set cnLevel = New ADODB.Connection
' Provide the connection string.
Dim strConn As String

'Use the SQL Server OLE DB Provider.
strConn = "PROVIDER=SQLOLEDB;"

'Connect to the Pubs database on the local server.
strConn = strConn & "DATA SOURCE=mydata;INITIAL 
CATALOG=myCat;Trusted_Connection=Yes"

'Now open the connection.
cnLevel.Open strConn
' Create a recordset object.
Dim rsLevel As ADODB.Recordset
Set rsLevel = New ADODB.Recordset

With rsLevel
    ' Assign the Connection object.
    .ActiveConnection = cnLevel
    ' Extract the required records.
    .Open "SELECT * FROM vw_HighPrice"
    ' Copy the records into cell A1 on Sheet1.
    Sheet1.Range("A1").CopyFromRecordset rsLevel
    
    ' Tidy up
    .Close
    .Open "SELECT * FROM vw_MidPrice"
    ' Copy the records into cell A2 on Sheet1.
    Sheet1.Range("A2").CopyFromRecordset rsLevel
    
    ' Tidy up
    .Close
    .Open "SELECT * FROM vw_LowPrice"
    ' Copy the records into cell A3 on Sheet1.
    Sheet1.Range("A3").CopyFromRecordset rsLevel
    
   
    ' Tidy up
    .Close
End With

cnLevel.Close
Set rsLevel = Nothing
Set cnLevel = Nothing
End Sub

The code reads lines from the sql view files and excel parses it into say 4 
data fields.  The code works well in Excel.   I wish to access the same data 
within the vb net project.

The data in the sql is constantly updated and repeatedly needs to be 
accessed by the VB net project.




3.Newbie Questions on ADO.NET in VB.NET(basically ADO.NET questions)

ok.  I have a basic understanding of the dataset but still more questions
than answers.

For example, if you use the Server Explorer to create connections, and then
wizards to generate datasets...

1.)  What if this is an app that you will redistribute and not a corporate
app where these connections are fixed?  What do those GUI representations
really mean in terms of code and how do you allow the user to change where
that connection points--I.e. computername, sqlservername, database name
,etc.

2.)  Isn't a dataset a lot of overkill?  I get this dataset and load it with
separate tables with tons of data so that I don't have to reconnect to the
database--that is the purpose right?  Then if that is a lot of data that is
a lot of network traffic and client memory used up right?  Also if I get
just a portion of the data then if I want more I must hit the database again
anyway.  Also, if I make updates then I have to write code to try to deal
with collisions.

What do you do if User A enters a lot of stuff and then User B does two...
both try to update the dataset to the database and one gets failures--does
that mean I tell him... sorry all your work for the last 30minutes couldn't
be done and dump it?

I guess I just don't get it..  Seems like a whole lot more work than
benefit.  I have seen a few instances where I could see the dataset being
useful--like getting a bunch of data to just display and sort etc.  But when
it comes to adding data etc.  Seems teh direct approach with sqlcommands and
stored procs is more sensible.

Then do you just create a dataset for the whole project and use the same one
for each form--is it globally available, or is the xsd file just a spec that
I use to create a new one in each form as needed?

Am I totally lost here?

Any ideas would be appreciated.   As you can see I know enough to be
dangerous but still fail to get the big picture and think that it all has to
be easier than what I can see and that also these GUI items in the IDE like
the Server Explorer have to make life easier... But I honestly haven't been
using it so far for my connections--just code--because I know what that does
and how to allow the user to change it.

Thanks,

Shane



4.Book "Pro ADO.NET with VB.Net 1.1" Sample Code Problem

I cannot open the sample code for the book "Pro ADO.NET with VB.Net 1.1." I 
get a message:

 "Unable to read the project file "WinSample.vbproj'. The project 
'WinSample.vbproj' was created with a newer version of Visual Studio which 
is incompatible with your version. You can only open this project with newer 
versions of Visual Studio."

I have VS.NET 2002 Version 7.0.9955. On the dialog, "About Microsoft 
Development Environment", it also lists .NET Framework 1.0. Version 
1.0.3705, but I do have .NET Framework 1.1 installed along with 1.1 Hotfix 
(KB886903).

Can I fix this problem? If so, how?

Thanks... 


5.How do I do this VB6 ADO code in ADO .NET

Below is a short simple ADO in VB6.  I have been messing with this most of 
the day trying to do the same thing in VB .NET ADO.NET.  Can anyone give me a 
clue where to look next?

I think I got the connection figured out, but I usually connect once at the 
beginning of the program globally, but this seems to only let me declare the 
Connection in the class I am in.  Sorry for all the dumb questions, still 
learning.

THANK YOU!

BaseConnStr = "Provider=MSDataShape.1;Persist Security Info=True;Data 
Provider=SQLOLEDB.1;Trusted_Connection=yes ;Data Source=xx;User 
ID=xx;Password=xx;Initial Catalog=xx"


CN.Open BaseConnStr

RS.Open "Select top 10 name from customer ", CN, adOpenStatic, adLockReadOnly

While Not RS.EOF

 Text1.Text = Text1.Text & RS.Fields("name").Value & vbCrLf
 
 RS.MoveNext
 
 Wend
 
 RS.Close
 Set RS = Nothing

6. newbie vb6 ADO to vb.net ado.net, paging

7. ADO.NET Component and VB6 client - ADO.Net or ADO 2.7

8. VB.net/ADO.net ADO Wrapper....



Return to dotnet framework

 

Who is online

Users browsing this forum: No registered users and 89 guest