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