473,804 Members | 3,308 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HLP: Opening Access DB issues

VB.net 2003; MS Access db; Netframe 1.1

I wrote an Windows app for my last place of employment that opened and
modified a couple of MS Access db files. I did most of my programming at home
on Drive "C". And I used the Drag/Drop Data Items to create the Connection,
DataSet and DataAdapters.

The Access files were located on drives "P" and "S" at work, so I had VB.net
installed on my work PC so I could change the drives in the Connection Icons.

Now I no longer work at that place and they want me to make some changes. Of
course I can't as I don't have a drive P or S on my system. So I'm attempting
to get rid of the Data Icons and do the connection, Data set and adapters with
Code. And of course I'm getting all kinds of errors.

So I'm doing a Test app to find/fix my items. Right off the bat I can't even
establish a proper connection to a DB. The following is that code I'm using.

I get an ERROR at the FILL line (unhandled exception where "Value cannot be
null". But the access file opens just fine if I use the DATA Icons.

And... If I change the Fill line to:
daShenData.Fill Schema(dsShenDa ta, SchemaType.Sour ce, "SHENHrsTab le")
.... the error then says "The ConnectionStrin g property has not been
initialized".

************** CODE *************** *************** *************** **
Imports System.IO
Imports System.Data.Ole Db

' Connection String1 to SHENTSdata.mdb
Dim connString1 As String = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
Source=TSdbPath & SHENTSdata.mdb"

Dim OleDbConnection 1 As OleDbConnection = New OleDbConnection

' Data Adapter 1
Dim strSelect1 As String
strSelect1 = "SELECT Bill_Code, Dispersmts, Fri_Hrs, Job_Descrn,
Job_Number, Mileage," & _
"Mon_Hrs, Period_End_Date , PO_Order, Sat_Hrs, Sun_Hrs,
Thr_Hrs, Tue_Hrs," & _
"Wed_Hrs, Work_Descrn FROM SHENHrsTable"
Dim daShenData As New OleDbDataAdapte r(strSelect1, OleDbConnection 1)

' Dataset 1
Dim dsShenData As New DataSet

' Fill Dataset 1
daShenData.Fill (dsShenData.Tab les("SHENHrsTab le"))
'''daShenData.F illSchema(dsShe nData, SchemaType.Sour ce, "SHENHrsTab le")
*************** *************** *************** *************** ********

QUESTION #1:
How do I fix the No Null value issue (why is it doing this anyways)?

QUESTION #2:
When I get this to work, where is the best place to place this code in my
application? In the Form Load? Between Form Load and "Windows Form Designer
generated code"? In a Module? In a Public Sub? This is because I open and
edit the Data bases elsewhere so I don't really know how to make it more
'globally' available.

QUESTION #3:
(a bit off topic) Or should I forget the whole thing... stick with my DATA
Icons... and use the SUBST command to create Virtual Drives and Fake it that
way?

Thanks muchly

BruceF
Dec 6 '05 #1
16 1343
Mr. B wrote:
Imports System.IO
Imports System.Data.Ole Db

' Connection String1 to SHENTSdata.mdb
Dim connString1 As String = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
Source=TSdbPath & SHENTSdata.mdb"


Shouldn't that be
Dim connString1 As String = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source="
& Path.Combine(TS dbPath, SHENTSdata.mdb)

....and where have you defined TSdbPath?
If I'm accessing a resource which is in a different location between the
development and deployment environments, I keep separate web.config files
for each environment and store the appropriate string in each.

So, in web.config I might have:-
<configuratio n>
<appSettings>
<add key="sqlConnect ionString" value =
"Server=WHERE\E VER;Database=db ;Trusted_Connec tion=true" />
</appSettings>

etc, and a different value in the other web.config.

and to retrieve the value:-
Private sqlConnectionSt ring As String =
System.Configur ation.Configura tionSettings.Ap pSettings("sqlC onnectionString ")

HTH

Andrew
Dec 7 '05 #2
> The Access files were located on drives "P" and "S" at work, so I had
VB.net
installed on my work PC so I could change the drives in the Connection Icons.
Now I no longer work at that place and they want me to make some changes. Of course I can't as I don't have a drive P or S on my system.
What stops you from right-clicking on "My Network Places" and mapping an
appropriate pathed subdirectory on your hard disk as P or S drive?
QUESTION #3:
(a bit off topic) Or should I forget the whole thing... stick with my DATA
Icons... and use the SUBST command to create Virtual Drives and Fake it that way?


SUBST will effectively do the same thing

Stephen Howe
Dec 7 '05 #3
In addition to the other points that have been made, while you are declaring
the connString1 variable and assigning a value to it, nowhere in the code
that you have posted do you actually use it. It is not passed to the
connectionStrin g argument when instantiating the OleDbConnection object or
assigned to the ConnectionStrin g property of the object.

--
Brendan Reynolds

"Mr. B" <Us**@NoWhere.c om> wrote in message
news:ll******** *************** *********@4ax.c om...
VB.net 2003; MS Access db; Netframe 1.1

I wrote an Windows app for my last place of employment that opened and
modified a couple of MS Access db files. I did most of my programming at
home
on Drive "C". And I used the Drag/Drop Data Items to create the
Connection,
DataSet and DataAdapters.

The Access files were located on drives "P" and "S" at work, so I had
VB.net
installed on my work PC so I could change the drives in the Connection
Icons.

Now I no longer work at that place and they want me to make some changes.
Of
course I can't as I don't have a drive P or S on my system. So I'm
attempting
to get rid of the Data Icons and do the connection, Data set and adapters
with
Code. And of course I'm getting all kinds of errors.

So I'm doing a Test app to find/fix my items. Right off the bat I can't
even
establish a proper connection to a DB. The following is that code I'm
using.

I get an ERROR at the FILL line (unhandled exception where "Value cannot
be
null". But the access file opens just fine if I use the DATA Icons.

And... If I change the Fill line to:
daShenData.Fill Schema(dsShenDa ta, SchemaType.Sour ce, "SHENHrsTab le")
... the error then says "The ConnectionStrin g property has not been
initialized".

************** CODE *************** *************** *************** **
Imports System.IO
Imports System.Data.Ole Db

' Connection String1 to SHENTSdata.mdb
Dim connString1 As String = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
Source=TSdbPath & SHENTSdata.mdb"

Dim OleDbConnection 1 As OleDbConnection = New OleDbConnection

' Data Adapter 1
Dim strSelect1 As String
strSelect1 = "SELECT Bill_Code, Dispersmts, Fri_Hrs, Job_Descrn,
Job_Number, Mileage," & _
"Mon_Hrs, Period_End_Date , PO_Order, Sat_Hrs, Sun_Hrs,
Thr_Hrs, Tue_Hrs," & _
"Wed_Hrs, Work_Descrn FROM SHENHrsTable"
Dim daShenData As New OleDbDataAdapte r(strSelect1, OleDbConnection 1)

' Dataset 1
Dim dsShenData As New DataSet

' Fill Dataset 1
daShenData.Fill (dsShenData.Tab les("SHENHrsTab le"))
'''daShenData.F illSchema(dsShe nData, SchemaType.Sour ce, "SHENHrsTab le")
*************** *************** *************** *************** ********

QUESTION #1:
How do I fix the No Null value issue (why is it doing this anyways)?

QUESTION #2:
When I get this to work, where is the best place to place this code in my
application? In the Form Load? Between Form Load and "Windows Form
Designer
generated code"? In a Module? In a Public Sub? This is because I open
and
edit the Data bases elsewhere so I don't really know how to make it more
'globally' available.

QUESTION #3:
(a bit off topic) Or should I forget the whole thing... stick with my DATA
Icons... and use the SUBST command to create Virtual Drives and Fake it
that
way?

Thanks muchly

BruceF

Dec 7 '05 #4
On Tue, 06 Dec 2005 20:38:29 GMT, Mr. B <Us**@NoWhere.c om> wrote:

¤ VB.net 2003; MS Access db; Netframe 1.1
¤
¤ I wrote an Windows app for my last place of employment that opened and
¤ modified a couple of MS Access db files. I did most of my programming at home
¤ on Drive "C". And I used the Drag/Drop Data Items to create the Connection,
¤ DataSet and DataAdapters.
¤
¤ The Access files were located on drives "P" and "S" at work, so I had VB.net
¤ installed on my work PC so I could change the drives in the Connection Icons.
¤
¤ Now I no longer work at that place and they want me to make some changes. Of
¤ course I can't as I don't have a drive P or S on my system. So I'm attempting
¤ to get rid of the Data Icons and do the connection, Data set and adapters with
¤ Code. And of course I'm getting all kinds of errors.
¤
¤ So I'm doing a Test app to find/fix my items. Right off the bat I can't even
¤ establish a proper connection to a DB. The following is that code I'm using.
¤
¤ I get an ERROR at the FILL line (unhandled exception where "Value cannot be
¤ null". But the access file opens just fine if I use the DATA Icons.
¤
¤ And... If I change the Fill line to:
¤ daShenData.Fill Schema(dsShenDa ta, SchemaType.Sour ce, "SHENHrsTab le")
¤ ... the error then says "The ConnectionStrin g property has not been
¤ initialized".
¤
¤ ************** CODE *************** *************** *************** **
¤ Imports System.IO
¤ Imports System.Data.Ole Db
¤
¤ ' Connection String1 to SHENTSdata.mdb
¤ Dim connString1 As String = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
¤ Source=TSdbPath & SHENTSdata.mdb"
¤
¤ Dim OleDbConnection 1 As OleDbConnection = New OleDbConnection
¤
¤ ' Data Adapter 1
¤ Dim strSelect1 As String
¤ strSelect1 = "SELECT Bill_Code, Dispersmts, Fri_Hrs, Job_Descrn,
¤ Job_Number, Mileage," & _
¤ "Mon_Hrs, Period_End_Date , PO_Order, Sat_Hrs, Sun_Hrs,
¤ Thr_Hrs, Tue_Hrs," & _
¤ "Wed_Hrs, Work_Descrn FROM SHENHrsTable"
¤ Dim daShenData As New OleDbDataAdapte r(strSelect1, OleDbConnection 1)
¤
¤ ' Dataset 1
¤ Dim dsShenData As New DataSet
¤
¤ ' Fill Dataset 1
¤ daShenData.Fill (dsShenData.Tab les("SHENHrsTab le"))
¤ '''daShenData.F illSchema(dsShe nData, SchemaType.Sour ce, "SHENHrsTab le")
¤ *************** *************** *************** *************** ********
¤
¤ QUESTION #1:
¤ How do I fix the No Null value issue (why is it doing this anyways)?
¤
¤ QUESTION #2:
¤ When I get this to work, where is the best place to place this code in my
¤ application? In the Form Load? Between Form Load and "Windows Form Designer
¤ generated code"? In a Module? In a Public Sub? This is because I open and
¤ edit the Data bases elsewhere so I don't really know how to make it more
¤ 'globally' available.
¤
¤ QUESTION #3:
¤ (a bit off topic) Or should I forget the whole thing... stick with my DATA
¤ Icons... and use the SUBST command to create Virtual Drives and Fake it that
¤ way?
¤

Where is the line of code where you Open the OleDbConnection 1 object?

Typically you open and close connections as you need them instead of maintaining persistent
connections. In this instance you probably want to add a Sub or Function to your Form and call it
from your Form Load event.

You can use the data connection objects (DATA Icons you called them) you created with the wizard,
but you need to change the connection string property at runtime (either in your Sub Main or Form
Load event).
Paul
~~~~
Microsoft MVP (Visual Basic)
Dec 7 '05 #5
With Deft Fingers, Paul Clement <Us************ ***********@sws pectrum.com>
wrote:

Where is the line of code where you Open the OleDbConnection 1 object?
So far it all has been in the Form Load. Just as I posted it.
Typically you open and close connections as you need them instead of maintaining persistent
connections. In this instance you probably want to add a Sub or Function to your Form and call it
from your Form Load event.
Okay. Using the 'Data Icons' I pretty well didn't have to do that as such.
You can use the data connection objects (DATA Icons you called them) you created with the wizard,
but you need to change the connection string property at runtime (either in your Sub Main or Form
Load event).


Thanks Paul!

BruceF
Dec 7 '05 #6
With Deft Fingers, "Andrew Morton" <ak*@in-press.co.uk.inv alid> wrote:
' Connection String1 to SHENTSdata.mdb
Dim connString1 As String = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
Source=TSdbPath & SHENTSdata.mdb"
Shouldn't that be
Dim connString1 As String = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source="
& Path.Combine(TS dbPath, SHENTSdata.mdb)


Well... good point. And the answer is I don't know. First off, I never got
any erry at that point, so I guess (to me) that it was okay.

But I just tried that and my "daShenData.Fil lSchema" line gives an error.
...and where have you defined TSdbPath?
It was a typical DIM statement after the "Inherits System.Windows. Forms.Form".
I just didn't think that was relevant (mind you I can see that you guys might
have thought that I missed that <grin>).
If I'm accessing a resource which is in a different location between the
development and deployment environments, I keep separate web.config files
for each environment and store the appropriate string in each.


Thanks Andrew... that's probably how I'll go.

Regards,

BruceF
Dec 7 '05 #7
With Deft Fingers, "Stephen Howe" <stephenPOINTho weATtns-globalPOINTcom>
wrote:
Now I no longer work at that place and they want me to make some changes.

Of
course I can't as I don't have a drive P or S on my system.


What stops you from right-clicking on "My Network Places" and mapping an
appropriate pathed subdirectory on your hard disk as P or S drive?


Well you know... I didn't even think about trying that. For the simple reason
that I'm now working ot of my Home (SOHO). And thus I don't have any
'network'. So while I am very familiar with that method, I just didn't even
think about it for Home use. But for sure, a much better way of doing it (I
was raised up on DOS <grin>).

Thanks!

Regards,

BruceF
Dec 7 '05 #8
With Deft Fingers, "Brendan Reynolds" <br******@discu ssions.microsof t.com>
wrote:
In addition to the other points that have been made, while you are declaring
the connString1 variable and assigning a value to it, nowhere in the code
that you have posted do you actually use it. It is not passed to the
connectionStri ng argument when instantiating the OleDbConnection object or
assigned to the ConnectionStrin g property of the object.


Okay Brendan... you kind of lost me here on what you said :(

What do you mean that it is not pass to the ConnectionStrin g argument?

Regards,

BruceF
Dec 7 '05 #9
> Okay Brendan... you kind of lost me here on what you said :(

What do you mean that it is not pass to the ConnectionStrin g argument?


Have a look at the code you posted.

See where you initialise connString1?
Now where is connString1 used in OleDbConnection 1 below? Don't see it.

Stephen Howe

Dec 7 '05 #10

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

Similar topics

0
1315
by: Madmax | last post by:
I am trying to use the .hlp file (an old help from for an existing app) in my application .Although the file shows up but it does not open the desired search string this is what I am doing string strHelp = C:\myfolder\ABC.HLP"; //its a hlp file Help.ShowHelp(this, strHelp,"Glossary");
11
3530
by: emailus | last post by:
I am webmaster for the domain <www.alpha1.org.au>. Not being an expert in html, I take advantage of my domain Registrant's web building tool, 'Instant Website'. This tool is provided as part of the fee I pay for web hosting. 'Instant Website' provides the option of having your opening page as a Flash Page, which you'll see if you visit <www.alpha1.org.au>. Well, you'll see it if you visit from a Windows machine. For some reason, when...
2
1773
by: HornyAZNBoy | last post by:
I've just wrote a hlp file to a program I just completed. Now I want to open that hlp file with a command on my program. I've tried using the Call Shell(C:/WINDOWS/Cris/desktop/MS Skill Book/Skill Book.exe) method and it works fine, but now I want to send it to a friend and I want him to be able to open that hlp file, but his computer name isn't Cris. Any suggestions? I've also tried this method and it is not working. Command1_Click()...
0
2027
by: bbrewder | last post by:
I am struggling with some MSAccess automation issues. Basically, we have a .Net application that uses MSAccess for reporting (legacy code). We are able to launch MSAccess fine and even work with the MSAccess COM objects to run our reports (using GetObject(<MDB Path>) - see http://support.microsoft.com/default.aspx?scid=kb;en-us;317113&Product=vbNET for info on how to do this). The problem that we are running into is that if our Access...
0
9706
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10326
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10317
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9143
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6851
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5520
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4295
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.