473,412 Members | 2,281 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

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
OleDBConnection1 along with the OleDbDataAdapter1 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.Students which is the name
of my Access table (Students.mdb).

I am receiving an error message stating "An unhandled exception of type
'System.Security.SecurityException' occurred in DatabaseTests.exe

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 2007
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.com" <fo***@DotNetMonster.com> wrote in
message news:53***********@DotNetMonster.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=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;Jet
OLEDB:System Database=system.mdw;"

Password
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;Jet
OLEDB:Database Password=MyDbPassword;"

If not try this:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;User
Id=admin;Password=;"

Nov 21 '05 #6
"CM Manager via DotNetMonster.com" <fo***@DotNetMonster.com> wrote in
message news:53***********@DotNetMonster.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.
InitializeComponent()

'Add any initialization after the InitializeComponent() 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.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'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 OleDbSelectCommand1 As System.Data.OleDb.OleDbCommand
Friend WithEvents OleDbInsertCommand1 As System.Data.OleDb.OleDbCommand
Friend WithEvents OleDbConnection1 As System.Data.OleDb.OleDbConnection
Friend WithEvents OleDbDataAdapter1 As System.Data.OleDb.OleDbDataAdapter
Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
Friend WithEvents DataSet11 As TestDBApp.DataSet1
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.OleDbSelectCommand1 = New System.Data.OleDb.OleDbCommand
Me.OleDbInsertCommand1 = New System.Data.OleDb.OleDbCommand
Me.OleDbConnection1 = New System.Data.OleDb.OleDbConnection
Me.OleDbDataAdapter1 = New System.Data.OleDb.OleDbDataAdapter
Me.DataGrid1 = New System.Windows.Forms.DataGrid
Me.DataSet11 = New TestDBApp.DataSet1
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).
BeginInit()
CType(Me.DataSet11, System.ComponentModel.ISupportInitialize).
BeginInit()
Me.SuspendLayout()
'
'OleDbSelectCommand1
'
Me.OleDbSelectCommand1.CommandText = "SELECT Grade, Name FROM
Students"
Me.OleDbSelectCommand1.Connection = Me.OleDbConnection1
'
'OleDbInsertCommand1
'
Me.OleDbInsertCommand1.CommandText = "INSERT INTO Students(Grade,
Name) VALUES (?, ?)"
Me.OleDbInsertCommand1.Connection = Me.OleDbConnection1
Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.
OleDbParameter("Grade", System.Data.OleDb.OleDbType.VarWChar, 50, "Grade"))
Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.
OleDbParameter("Name", System.Data.OleDb.OleDbType.VarWChar, 50, "Name"))
'
'OleDbConnection1
'
Me.OleDbConnection1.ConnectionString = "Jet OLEDB:Global Partial Bulk
Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database L" & _
"ocking Mode=1;Data Source=""H:\Visual Basic .NET\Students.mdb"";Jet
OLEDB:Engine T" & _
"ype=5;Provider=""Microsoft.Jet.OLEDB.4.0"";Je t OLEDB:System
database=;Jet OLEDB:SF" & _
"P=False;persist security info=False;Extended Properties=;Mode=Share
Deny None;Je" & _
"t OLEDB:Encrypt Database=False;Jet OLEDB:Create System
Database=False;Jet OLEDB:" & _
"Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica
Repair=Fals" & _
"e;User ID=Admin;Jet OLEDB:Global Bulk Transactions=1"
'
'OleDbDataAdapter1
'
Me.OleDbDataAdapter1.InsertCommand = Me.OleDbInsertCommand1
Me.OleDbDataAdapter1.SelectCommand = Me.OleDbSelectCommand1
Me.OleDbDataAdapter1.TableMappings.AddRange(New System.Data.Common.
DataTableMapping() {New System.Data.Common.DataTableMapping("Table",
"Students", New System.Data.Common.DataColumnMapping() {New System.Data.
Common.DataColumnMapping("Grade", "Grade"), New System.Data.Common.
DataColumnMapping("Name", "Name")})})
'
'DataGrid1
'
Me.DataGrid1.DataMember = ""
Me.DataGrid1.DataSource = Me.DataSet11.Students
Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.
ControlText
Me.DataGrid1.Location = New System.Drawing.Point(64, 48)
Me.DataGrid1.Name = "DataGrid1"
Me.DataGrid1.Size = New System.Drawing.Size(272, 232)
Me.DataGrid1.TabIndex = 0
'
'DataSet11
'
Me.DataSet11.DataSetName = "DataSet1"
Me.DataSet11.Locale = New System.Globalization.CultureInfo("en-US")
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(72, 336)
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 1
Me.Button1.Text = "Load Data"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(256, 336)
Me.Button2.Name = "Button2"
Me.Button2.TabIndex = 2
Me.Button2.Text = "Save Data"
'
'Form1
'
Me.AutoScaleBaseSize = 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.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit
()
CType(Me.DataSet11, System.ComponentModel.ISupportInitialize).EndInit
()
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
DataSet11.Clear()
OleDbDataAdapter1.Fill(DataSet11)
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
OleDbDataAdapter1.Update(DataSet11)
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.remember 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

No!.Bra try not to use the full path when assigning the data source,
reason being what if you move the file?.It will give you errors.Try to
copy the file into the same subdirectory as your solution, so that you
can only use ..\..\student.mdb when referencing it in your code.

DFace

*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #11
Terry wrote:
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.


I've tried also using the Data Form Wizard to create my form. I'm able to
create the data connection using Server Explorer no problem. I used MS Jet 4.
0 OLE DB Provider and tested the connection with no problem. I've just put a
data grid on the form with two buttons called Load Data and Save Data.

The "Load Data" button has the following code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.
EventArgs) Handles Button1.Click
DataSet11.Clear()
OleDbDataAdapter1.Fill(DataSet11)
End Sub

The "Save Data" button has the following code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.
EventArgs) Handles Button2.Click
OleDbDataAdapter1.Update(DataSet11)
End Sub

Everything else are defaults and I'm still getting the stupid Exception error
message. Is there something possibly that wasn't installed when I installed
VB.NET 2003, perhaps as part of a Custom installation that may be missing? I
would think it would be simple to load an Access database, but am having no
luck.
--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...b-net/200508/1
Nov 21 '05 #12

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

Similar topics

5
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...
1
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...
12
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...
16
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,...
5
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...
15
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...
2
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...
0
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...
21
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...
6
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
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...
0
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...
0
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,...
0
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...

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.