HLP: Updating my Access Connection Code from Toolbox Icons

M

Mr. B

Over a year ago, I did my first VB.net application with an Access db. Because
at that time, I was not familar with how to manipulate DB's, I used the drag
on Icons under 'DATA' in the Toolbox to do my Connections, Data Adapters and
DataSets.

Now I want to do the actual Code for them as I want to better understand and
control them, etc. I have started to attack my application with this in mind.
And I'm making some success. But I've hit a wall on an issue (and hopefully
it will be my only one).

I had the following Icon names:

Connection: OleDbConnection1
Data Adapter: daTSUpdate
Dataset: dsTSUpdate

My Code so far is thus (watch out for word wrapping):

' Connection String to OmiTSMaster.mdb
Dim FullDataPath As String = mdbDataPath & "\ExtraServicesData.mdb"
Dim connString2 As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=FullDataPath"
Dim OleDbConnection1 As OleDbConnection = New OleDbConnection
OleDbConnection1.ConnectionString = connString1

' Data Adapter 1
Dim daTSUpdate As OleDbDataAdapter = New OleDbDataAdapter("SELECT Amount,
Category, Chargeout_Level, Class, Cost_Code, Description, Description1,
Description2, Employee, Employee_Name, Employee1, Group_Cost_Code, ID, Job,
Pay_ID, Pay_ID1, Pay_Type", OleDbConnection1)

' New Dataset 1
Dim DsTSUpdate As DataSet = New DataSet


Now... when I came to Fill my Dataset, originally I had the following Code:
' Fill Dataset
daTSUpdate.Fill(DsTSUpdate, "TSUpdate")

But that gave me an error... so I figured this out (at least it didn't give me
an error):
' Fill Dataset
daTSUpdate.Fill(DsTSUpdate.Tables("TSUpdate"))


But later on in my Code, I have several more errors (which are similar as the
following line):
Dim dtProject As DataTable = dsTSUpdate.TSUpdate

The Error always is the "dsTSUpdate.TSUpdate" part. I can't figure out how to
fix this. I've tried several ideas, but they all show an error. But it
worked just fine when I used the Toolbox Icons to create all the connections,
etc. (scratching my head on this).

Anyone know what I need to do? Much appreciated!

Regards,

Bruce F
 
C

Cor Ligthert [MVP]

Mr B.

You are crossposting to the ADO newsgroups. These are completly irelevant in
your question. I think that the guys and girls in that newsgroup are not
happy with you when after reading the see that your post is completly
irreleveant.

To get an answer you can have a look at our website. There are a lot of
samples that include what you ask.

By instance this one, however there are much more that include complete
dataaccess.

http://www.windowsformsdatagridhelp.com/default.aspx?ID=9c2ca38c-92c1-410f-b753-528cf4c49e94

This one shows you all information about a datatable in access.

The designer creates code that completly fits everything, mostly is it a
little bit overdone.

I hope this helps,

Cor
 
M

Mr. B

Cor Ligthert said:
Mr B.

You are crossposting to the ADO newsgroups. These are completly irelevant in
your question. I think that the guys and girls in that newsgroup are not
happy with you when after reading the see that your post is completly
irreleveant.

Sorry... those three NG's are the ones I've usually posted to on DB questions
:(
To get an answer you can have a look at our website. There are a lot of
samples that include what you ask.
This one shows you all information about a datatable in access.

Thanks... any help is appreciated.

Regards,

Bruce F
 
S

Sahil Malik [MVP]

Okay, now it is a bit hard to diagnose what the reason for the error maybe,
without actually knowing what the actual text of the error is.

Specifically, this
daTSUpdate.Fill(DsTSUpdate, "TSUpdate")

versus this,
daTSUpdate.Fill(DsTSUpdate.Tables("TSUpdate"))

Are not functionally very different (and again this really depends on the
structure of your strongly typed db).

It would really help if you could post the actual error messages.
 
M

Mr. B

Sahil Malik said:
Okay, now it is a bit hard to diagnose what the reason for the error maybe,
without actually knowing what the actual text of the error is.

Specifically, this

versus this,

Are not functionally very different (and again this really depends on the
structure of your strongly typed db).

It would really help if you could post the actual error messages.

Sorry for the delay... the error states:

An unhandled exception of type "System.Data.OleDb.OleDbException" occured in
System.Data.dll

Regards,

Bruce F
 
S

Sahil Malik [MVP]

Crap .. thats the worst error to get in OleDb. All I can say is, it's not
from within ADO.NET, but the underlying COM DLLS.

Try isolating the commands being sent and execute them through VBScript ADO
Classic, see if the error persists.

- SM
 
M

Mr. B

Sahil Malik said:
Crap .. thats the worst error to get in OleDb. All I can say is, it's not
from within ADO.NET, but the underlying COM DLLS.

Try isolating the commands being sent and execute them through VBScript ADO
Classic, see if the error persists.

Well... unfortunately I don't know how to execute them through VBScript ADO
Classic. (sigh - I'm just a week end programmer - mostly for fun).

The strange thing is that my application works just FINE if I use the drag
on Icons under 'DATA' in the Toolbox.

All I want to do is to be able to change the Path to the Access DB's using a
Command Line string. This way my company can change the folder name and I
don't have to hard code the path each time.

But I get all kinds of errors and problems as I start to remove the DATA icons
and use Code instead.

Is there a way to 'over-ride' the path to the DB files that are within the
Data Icons (ie: the Location icon called: OleDbConnection1)? If I can do that
at Run Time, I can leave all of them alone (hopefully).

If not... I'll just fight through it or leave the application as is (sigh).

Thanks anyways.

Regards,

Bruce F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top