473,765 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help in VB.NET connecting to Access database

I am very frustrated due to this exception error I am receiving. I've tried
searching numerous user support groups, Microsoft Support Net, Google, etc.
and haven't found exactly my situation. Hopefully someone here can help.

I am just learning VB.NET and purchased the SAM's "Teach Yourself VB.NET
2003 in 21 days' book. I am trying to connect to an Access database I created
locally on my computer per Chapter 16. I originally had it on a network share
but have also tried accessing it on my C:\ drive. I've created an
OleDBConnection 1 along with the OleDbDataAdapte r1 and the DataSet11 per the
book's instructions. I dragged a data grid onto a blank form and in the
Properties window set its Datasource > DataSet11.Stude nts which is the name
of my Access table (Students.mdb).

I am receiving an error message stating "An unhandled exception of type
'System.Securit y.SecurityExcep tion' occurred in DatabaseTests.e xe

Additional information: Request failed" I've seen this probably has something
to do with my permissions which I can adjust in the Microsoft .NET Framework
Configuration utility, but I don't know what I'm looking for. Can someone
please assist with troubleshooting this issue? Let me know if you need any
additional information. Thank you!
--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #1
11 2052
Does the asp worker process have rights to the directory where the mdb
file is located?

Nov 21 '05 #2
Terry wrote:
Does the asp worker process have rights to the directory where the mdb
file is located?


I don't know because I don't know where the asp worker process rights are
configured. What is the name of the config file where this is configured and
where by default is it stored?
--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #3
Is this a web app or a windows app?
"CM Manager via DotNetMonster.c om" <fo***@DotNetMo nster.com> wrote in
message news:53******** ***@DotNetMonst er.com...
Terry wrote:
Does the asp worker process have rights to the directory where the mdb
file is located?


I don't know because I don't know where the asp worker process rights are
configured. What is the name of the config file where this is configured
and
where by default is it stored?
--
Message posted via http://www.dotnetmonster.com

Nov 21 '05 #4
Rick Mogstad wrote:
Is this a web app or a windows app?
Does the asp worker process have rights to the directory where the mdb
file is located?

[quoted text clipped - 3 lines]
and
where by default is it stored?


It is a windows app. I've tried storing the VB code as well as the Access
database *.mdb file both locally on my C:\ drive as well as on a network
share drive. I get the same exception error message either way.
--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #5
Does the mdb use security? If so try these as your connection string.

Workgroup
"Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=\somepat h\mydb.mdb;Jet
OLEDB:System Database=system .mdw;"

Password
"Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=\somepat h\mydb.mdb;Jet
OLEDB:Database Password=MyDbPa ssword;"

If not try this:
"Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=\somepat h\mydb.mdb;User
Id=admin;Passwo rd=;"

Nov 21 '05 #6
"CM Manager via DotNetMonster.c om" <fo***@DotNetMo nster.com> wrote in
message news:53******** ***@DotNetMonst er.com...
Rick Mogstad wrote:
Is this a web app or a windows app?
Does the asp worker process have rights to the directory where the mdb
file is located?

[quoted text clipped - 3 lines]
and
where by default is it stored?


It is a windows app. I've tried storing the VB code as well as the Access
database *.mdb file both locally on my C:\ drive as well as on a network
share drive. I get the same exception error message either way.
--
Message posted via http://www.dotnetmonster.com


Hi,

Please post your code.

Have you tried opening the mdb file directly?

Landers
Nov 21 '05 #7
landers wrote:
Is this a web app or a windows app?

[quoted text clipped - 7 lines]
database *.mdb file both locally on my C:\ drive as well as on a network
share drive. I get the same exception error message either way.


Hi,

Please post your code.

Have you tried opening the mdb file directly?

Landers


Here is the code. It is very simple. A form with a data grid to load an
Access table. One button to load the data grid and another to update the
Access database. There is no security on the database as right now this is
just a test to learn how to establish database connectivity and associating
windows app controls with table fields via data binding.

Public Class Form1
Inherits System.Windows. Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeCompo nent()

'Add any initialization after the InitializeCompo nent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Disp ose()
End If
End If
MyBase.Dispose( disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.Componen tModel.IContain er

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents OleDbSelectComm and1 As System.Data.Ole Db.OleDbCommand
Friend WithEvents OleDbInsertComm and1 As System.Data.Ole Db.OleDbCommand
Friend WithEvents OleDbConnection 1 As System.Data.Ole Db.OleDbConnect ion
Friend WithEvents OleDbDataAdapte r1 As System.Data.Ole Db.OleDbDataAda pter
Friend WithEvents DataGrid1 As System.Windows. Forms.DataGrid
Friend WithEvents DataSet11 As TestDBApp.DataS et1
Friend WithEvents Button1 As System.Windows. Forms.Button
Friend WithEvents Button2 As System.Windows. Forms.Button
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
Me.OleDbSelectC ommand1 = New System.Data.Ole Db.OleDbCommand
Me.OleDbInsertC ommand1 = New System.Data.Ole Db.OleDbCommand
Me.OleDbConnect ion1 = New System.Data.Ole Db.OleDbConnect ion
Me.OleDbDataAda pter1 = New System.Data.Ole Db.OleDbDataAda pter
Me.DataGrid1 = New System.Windows. Forms.DataGrid
Me.DataSet11 = New TestDBApp.DataS et1
Me.Button1 = New System.Windows. Forms.Button
Me.Button2 = New System.Windows. Forms.Button
CType(Me.DataGr id1, System.Componen tModel.ISupport Initialize).
BeginInit()
CType(Me.DataSe t11, System.Componen tModel.ISupport Initialize).
BeginInit()
Me.SuspendLayou t()
'
'OleDbSelectCom mand1
'
Me.OleDbSelectC ommand1.Command Text = "SELECT Grade, Name FROM
Students"
Me.OleDbSelectC ommand1.Connect ion = Me.OleDbConnect ion1
'
'OleDbInsertCom mand1
'
Me.OleDbInsertC ommand1.Command Text = "INSERT INTO Students(Grade,
Name) VALUES (?, ?)"
Me.OleDbInsertC ommand1.Connect ion = Me.OleDbConnect ion1
Me.OleDbInsertC ommand1.Paramet ers.Add(New System.Data.Ole Db.
OleDbParameter( "Grade", System.Data.Ole Db.OleDbType.Va rWChar, 50, "Grade"))
Me.OleDbInsertC ommand1.Paramet ers.Add(New System.Data.Ole Db.
OleDbParameter( "Name", System.Data.Ole Db.OleDbType.Va rWChar, 50, "Name"))
'
'OleDbConnectio n1
'
Me.OleDbConnect ion1.Connection String = "Jet OLEDB:Global Partial Bulk
Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database L" & _
"ocking Mode=1;Data Source=""H:\Vis ual Basic .NET\Students.m db"";Jet
OLEDB:Engine T" & _
"ype=5;Provider =""Microsoft.Je t.OLEDB.4.0"";J et OLEDB:System
database=;Jet OLEDB:SF" & _
"P=False;persis t security info=False;Exte nded Properties=;Mod e=Share
Deny None;Je" & _
"t OLEDB:Encrypt Database=False; Jet OLEDB:Create System
Database=False; Jet OLEDB:" & _
"Don't Copy Locale on Compact=False;J et OLEDB:Compact Without Replica
Repair=Fals" & _
"e;User ID=Admin;Jet OLEDB:Global Bulk Transactions=1"
'
'OleDbDataAdapt er1
'
Me.OleDbDataAda pter1.InsertCom mand = Me.OleDbInsertC ommand1
Me.OleDbDataAda pter1.SelectCom mand = Me.OleDbSelectC ommand1
Me.OleDbDataAda pter1.TableMapp ings.AddRange(N ew System.Data.Com mon.
DataTableMappin g() {New System.Data.Com mon.DataTableMa pping("Table",
"Students", New System.Data.Com mon.DataColumnM apping() {New System.Data.
Common.DataColu mnMapping("Grad e", "Grade"), New System.Data.Com mon.
DataColumnMappi ng("Name", "Name")})})
'
'DataGrid1
'
Me.DataGrid1.Da taMember = ""
Me.DataGrid1.Da taSource = Me.DataSet11.St udents
Me.DataGrid1.He aderForeColor = System.Drawing. SystemColors.
ControlText
Me.DataGrid1.Lo cation = New System.Drawing. Point(64, 48)
Me.DataGrid1.Na me = "DataGrid1"
Me.DataGrid1.Si ze = New System.Drawing. Size(272, 232)
Me.DataGrid1.Ta bIndex = 0
'
'DataSet11
'
Me.DataSet11.Da taSetName = "DataSet1"
Me.DataSet11.Lo cale = New System.Globaliz ation.CultureIn fo("en-US")
'
'Button1
'
Me.Button1.Loca tion = New System.Drawing. Point(72, 336)
Me.Button1.Name = "Button1"
Me.Button1.TabI ndex = 1
Me.Button1.Text = "Load Data"
'
'Button2
'
Me.Button2.Loca tion = New System.Drawing. Point(256, 336)
Me.Button2.Name = "Button2"
Me.Button2.TabI ndex = 2
Me.Button2.Text = "Save Data"
'
'Form1
'
Me.AutoScaleBas eSize = New System.Drawing. Size(5, 13)
Me.ClientSize = New System.Drawing. Size(408, 406)
Me.Controls.Add (Me.Button2)
Me.Controls.Add (Me.Button1)
Me.Controls.Add (Me.DataGrid1)
Me.Name = "Form1"
Me.Text = "Form1"
CType(Me.DataGr id1, System.Componen tModel.ISupport Initialize).End Init
()
CType(Me.DataSe t11, System.Componen tModel.ISupport Initialize).End Init
()
Me.ResumeLayout (False)

End Sub

#End Region

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
DataSet11.Clear ()
OleDbDataAdapte r1.Fill(DataSet 11)
End Sub

Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button2.Click
OleDbDataAdapte r1.Update(DataS et11)
End Sub
End Class
--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #8
Are you using Visual Studio .net to create the application? If so can
you connect to the MDB via the server explorer?

Add a new DB connecion. Then click to the provider tab change the
provier to MS Jet 4.0 OLE DB PRovider, then back to the Connection tab.
Pick your DB and test it.

Nov 21 '05 #9

I think you've changed the location of your file so many times now you
forgot to change the path.Maybe you forgot to change the permission
state and, create a new permission for yourself where the folder was
originally
alocated.rememb er this database is shared and you have just copied the
database without changing permission status.
*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #10

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

Similar topics

5
1754
by: news | last post by:
I have a new situation I'm facing and could use a suggestion or two, as I don't seem to be able to think in the abstract very well. We have a local server which holds all of our image files. We have a remote server that runs our public Web server and mySQL database. I need to be able to run a script that will: Read the contents of a dir on the local server and a. make thumbnails of the files in it b. querey the database and pull...
1
1813
by: Tim Dol | last post by:
I have inherited a VB6-SP5 program connecting to an Access 2000 database. I'm relatively new to VB/Access programming, so I may overlook something obvious. I'll try to explain the problem I can't solve. My VB executable and Access database are both stored in a shared folder on a Novell volume. The first user has a good performance, but the second user has to wait 9 seconds to open the first form. The third user has to wait 18 seconds,...
12
2791
by: Ann Marinas | last post by:
Hi all, I would like to ask for some help regarding separating the asp.net webserver and the sql server. I have created an asp.net application for a certain company. Initially, we installed both the iis and sql server in a single machine. Not too long ago, the machine had some hardware problems, and management has decided to purchase new servers, for both asp.net and sql server.
16
2314
by: peshekeedweller | last post by:
Using asp.net 1.1. vb.net 2003. I am trying to connect to a remote sql server 2000 on a virtual machine running windows 2000 server. I can connect through the server explorer in visual studio, but cannot connect through code. I have done it before and can not do it now; I don't know what changed. (I also cannot connect to local Access database through code though I can from server explorer.) The code is: conn = New SqlConnection("data...
5
2131
by: Sebastian | last post by:
I'm using the following code to connect to an access 2000 database. (with reference to adodb) Public DBvar As New ADODB.Connection() DBvar.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=Data.mdb", "userID", "Pass") Previously I was connecting with just DBvar.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data
15
4641
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to communicate with a MySQL database table on a web server, from inside of my company's Access-VBA application. I know VBA pretty well but have never before needed to do this HTTP/XML/MySQL type functions.
2
4126
by: Patrick F | last post by:
Hi, i have SQL Server 2005 and a database set that is called, myCompany the problem is that i cant connect from my page to it, here is from the web.config: ( i have got this connectionstring from my sqldataobject on my page) <add name="ConStr" connectionString="Data Source=localhost;Initial Catalog=myCompany;Integrated Security=True" providerName="System.Data.SqlClient" /> the strange part is that its trying to connect to a SQL express...
0
1548
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, I've my win32 application which connecting to my sql database. till now i used MSDE as my database and now i want to upgrade to sql express 2005. after the upgrade i tried to connect to the database and couldn't. i keep getting an error which saying that database doesn't exists or access is denied. is there something diffrent between connecting to MSDE and connecting to sql express 2005 ? here with my connection string.
21
4118
by: nihad.nasim | last post by:
Hi there, I have a database in Access that I need on the web. The web page should connect to the database and write records for certain tables and view records for others. I want to know a reliable way of connecting Access to a server. I am willing to switch to any version of Access which might solve the problem. Which server would you recommend and what are the advanatages and disadvantatges of the server you propose? Please also inlcude...
6
2985
by: zaina | last post by:
hi everybody i am nwebie in this forum but i think it is useful for me and the member are helpful my project is about connecting client with the server to start exchanging messages between them. to be more clear we process this purpose we serve this to the student in the university. how?? student will send a message that contains his name,id and request by format the server want such as zaina-20024008-grade. the grade is the request...
0
9398
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10156
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9951
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
9832
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7375
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
5275
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
5419
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3924
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
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.