473,568 Members | 2,762 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

myConnection.Op en() Error

This is the code that I am running can anyone help me
understand why I get the following error

An unhandled exception of
type 'System.Data.Ol eDb.OleDbExcept ion' occurred in
system.data.dll


' IMport Data and Oledb namespaces
Imports System.Data
Imports System.Data.Ole Db

Public Class Form1
Inherits System.Windows. Forms.Form
Dim myConnection As OleDbConnection = New _
OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;
database = c:\concord.mdb" )
Dim myDataAdapter As New OleDbDataAdapte r()
Dim myDataSet As DataSet = New DataSet()
Private Sub Form1_Load(ByVa l sender As System.Object,
ByVal e As System.EventArg s) Handles MyBase.Load
' Set the SelectCommand properties
myDataAdapter.S electCommand = New OleDbCommand()
myDataAdapter.S electCommand.Co nnection =
myConnection
myDataAdapter.S electCommand.Co mmandText = _
"SELECT CustNum, WorkPhone, Alt Phone,
Firstname, LastName, Address, Address1, City,
StateOrProvince " & _
"FROM customer " & _
"ORDER BY LastName, LastName"
myDataAdapter.S electCommand.Co mmandType =
CommandType.Tex t

' OPen the database connection
myConnection.Op en()
'Now execute the command
myDataAdapter.S electCommand.Ex ecuteNonQuery()
' Fill DataSet object with data
myDataAdapter.F ill(myDataSet, "customers" )

'Close the database connection
myConnection.Cl ose()
' Set the dataGrid properties to bind it to our
data
grdCustomerInfo .DataSource = myDataSet
grdCustomerInfo .DataMember = "customers"
End Sub
End Class
Nov 20 '05 #1
4 3955
Which line is crashing? Verify that the file Exists first... If
File.Exists("C: \concord.mdb") then if it does, make sure you that you have
persmissions to the file and to the database... If you have a username and
password, make sure you include the rest of the connectionstrin g.
http://www.connectionstrings.com . If that doesn't fix it, put a breakpoint
next to your commandtext once it's completed and make sure you can fire it
against Access itself without ADO.NET. If you could tell me where the
exception is being raised, it'd help a lot in diagnosing it.

HTH,

Bill

"SOlva" <an*******@disc ussions.microso ft.com> wrote in message
news:07******** *************** *****@phx.gbl.. .
This is the code that I am running can anyone help me
understand why I get the following error

An unhandled exception of
type 'System.Data.Ol eDb.OleDbExcept ion' occurred in
system.data.dll


' IMport Data and Oledb namespaces
Imports System.Data
Imports System.Data.Ole Db

Public Class Form1
Inherits System.Windows. Forms.Form
Dim myConnection As OleDbConnection = New _
OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;
database = c:\concord.mdb" )
Dim myDataAdapter As New OleDbDataAdapte r()
Dim myDataSet As DataSet = New DataSet()
Private Sub Form1_Load(ByVa l sender As System.Object,
ByVal e As System.EventArg s) Handles MyBase.Load
' Set the SelectCommand properties
myDataAdapter.S electCommand = New OleDbCommand()
myDataAdapter.S electCommand.Co nnection =
myConnection
myDataAdapter.S electCommand.Co mmandText = _
"SELECT CustNum, WorkPhone, Alt Phone,
Firstname, LastName, Address, Address1, City,
StateOrProvince " & _
"FROM customer " & _
"ORDER BY LastName, LastName"
myDataAdapter.S electCommand.Co mmandType =
CommandType.Tex t

' OPen the database connection
myConnection.Op en()
'Now execute the command
myDataAdapter.S electCommand.Ex ecuteNonQuery()
' Fill DataSet object with data
myDataAdapter.F ill(myDataSet, "customers" )

'Close the database connection
myConnection.Cl ose()
' Set the dataGrid properties to bind it to our
data
grdCustomerInfo .DataSource = myDataSet
grdCustomerInfo .DataMember = "customers"
End Sub
End Class

Nov 20 '05 #2
it is happening a t myConnecyion.Op en()
-----Original Message-----
Which line is crashing? Verify that the file Exists first... IfFile.Exists("C :\concord.mdb") then if it does, make sure you that you havepersmissions to the file and to the database... If you have a username andpassword, make sure you include the rest of the connectionstrin g.http://www.connectionstrings.com . If that doesn't fix it, put a breakpointnext to your commandtext once it's completed and make sure you can fire itagainst Access itself without ADO.NET. If you could tell me where theexception is being raised, it'd help a lot in diagnosing it.
HTH,

Bill

"SOlva" <an*******@disc ussions.microso ft.com> wrote in messagenews:07******* *************** ******@phx.gbl. ..
This is the code that I am running can anyone help me
understand why I get the following error

An unhandled exception of
type 'System.Data.Ol eDb.OleDbExcept ion' occurred in
system.data.dll


' IMport Data and Oledb namespaces
Imports System.Data
Imports System.Data.Ole Db

Public Class Form1
Inherits System.Windows. Forms.Form
Dim myConnection As OleDbConnection = New _
OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0; database = c:\concord.mdb" )
Dim myDataAdapter As New OleDbDataAdapte r()
Dim myDataSet As DataSet = New DataSet()
Private Sub Form1_Load(ByVa l sender As System.Object,
ByVal e As System.EventArg s) Handles MyBase.Load
' Set the SelectCommand properties
myDataAdapter.S electCommand = New OleDbCommand()
myDataAdapter.S electCommand.Co nnection =
myConnection
myDataAdapter.S electCommand.Co mmandText = _
"SELECT CustNum, WorkPhone, Alt Phone,
Firstname, LastName, Address, Address1, City,
StateOrProvince " & _
"FROM customer " & _
"ORDER BY LastName, LastName"
myDataAdapter.S electCommand.Co mmandType =
CommandType.Tex t

' OPen the database connection
myConnection.Op en()
'Now execute the command
myDataAdapter.S electCommand.Ex ecuteNonQuery()
' Fill DataSet object with data
myDataAdapter.F ill(myDataSet, "customers" )

'Close the database connection
myConnection.Cl ose()
' Set the dataGrid properties to bind it to our
data
grdCustomerInfo .DataSource = myDataSet
grdCustomerInfo .DataMember = "customers"
End Sub
End Class

.

Nov 20 '05 #3
I got passed that error now it is saying the same thing at
the myDataAdapter.S electCommand.Ex ecuteNonQuery() . Any
ideas I also sent you an email.
-----Original Message-----
Which line is crashing? Verify that the file Exists first... IfFile.Exists("C :\concord.mdb") then if it does, make sure you that you havepersmissions to the file and to the database... If you have a username andpassword, make sure you include the rest of the connectionstrin g.http://www.connectionstrings.com . If that doesn't fix it, put a breakpointnext to your commandtext once it's completed and make sure you can fire itagainst Access itself without ADO.NET. If you could tell me where theexception is being raised, it'd help a lot in diagnosing it.
HTH,

Bill

"SOlva" <an*******@disc ussions.microso ft.com> wrote in messagenews:07******* *************** ******@phx.gbl. ..
This is the code that I am running can anyone help me
understand why I get the following error

An unhandled exception of
type 'System.Data.Ol eDb.OleDbExcept ion' occurred in
system.data.dll


' IMport Data and Oledb namespaces
Imports System.Data
Imports System.Data.Ole Db

Public Class Form1
Inherits System.Windows. Forms.Form
Dim myConnection As OleDbConnection = New _
OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0; database = c:\concord.mdb" )
Dim myDataAdapter As New OleDbDataAdapte r()
Dim myDataSet As DataSet = New DataSet()
Private Sub Form1_Load(ByVa l sender As System.Object,
ByVal e As System.EventArg s) Handles MyBase.Load
' Set the SelectCommand properties
myDataAdapter.S electCommand = New OleDbCommand()
myDataAdapter.S electCommand.Co nnection =
myConnection
myDataAdapter.S electCommand.Co mmandText = _
"SELECT CustNum, WorkPhone, Alt Phone,
Firstname, LastName, Address, Address1, City,
StateOrProvince " & _
"FROM customer " & _
"ORDER BY LastName, LastName"
myDataAdapter.S electCommand.Co mmandType =
CommandType.Tex t

' OPen the database connection
myConnection.Op en()
'Now execute the command
myDataAdapter.S electCommand.Ex ecuteNonQuery()
' Fill DataSet object with data
myDataAdapter.F ill(myDataSet, "customers" )

'Close the database connection
myConnection.Cl ose()
' Set the dataGrid properties to bind it to our
data
grdCustomerInfo .DataSource = myDataSet
grdCustomerInfo .DataMember = "customers"
End Sub
End Class

.

Nov 20 '05 #4
Cor
Hi Anonymous,

Why are you using that
the myDataAdapter.S electCommand.Ex ecuteNonQuery() .


I do not understand why you need it

Why not try what happens when you set a ' before it

I hope this helps?

Cor
Nov 20 '05 #5

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

Similar topics

4
25008
by: Andras Gilicz | last post by:
Hi VB fans I'm working on a relatively large project in VB6 with about a dozen forms, including graphs, labels, text boxes, etc. The software itself is actually a flow simulator with more or less complex technical calculations, several input variables. I would like to equipp the starting panel with the usual New, Open, Save, Save As, Close...
4
7091
by: Corepaul | last post by:
I am working in Windows 2000 and Access 2000 and am a rookie in Access. Coding merrily along, I stop periodically to test that everything works. After adding a small amount of code to several events, when I try to run the form suddenly won't run. I get the message "The expression On Open you entered as the event property setting produced...
2
4086
by: Julia Baresch | last post by:
Hi everyone, As some of you may know, we've been having trouble with an unrecognized database format error. Today I installed an unfinished project on the workstation of one of my users. It's a query by form in which she enters the criteria of the record she wants in an unbound form, and it pulls only that record and switches to the...
0
7704
by: gm | last post by:
Immediately after generating the Access application from the Source Safe project I get: "-2147467259 Could not use ''; file already in use." If Access database closed and then reopened I get: "-2147467259 The database has been place in a state by user 'Admin' on machine ..... that prevents it from being opened or locked."
0
12020
by: bazzer | last post by:
hey, im trying to access a microsoft access database from an ASP.NET web application in visual basic 2003.NET. i get the following error when i try running it: Server Error in '/CinemaBookingSystem' Application. -------------------------------------------------------------------------------- ERROR General error Unable to open registry...
6
4426
by: aomighty | last post by:
I wanted to write the following code: import shelve try: db = shelve.open(file, "r") except SomeError: print "Oh no, db not found" Only, I'm not sure what SomeError should be. I tried error, anydbm.error, shelve.open.anydb.error, etc. but can't find it. Things
12
6234
by: Steve | last post by:
I have a database that raises an error when you try to open it and it doesn't open. Trying to open the database with the OpenDatabase method raises the same error. Trying to import any objects (tables, queies, forms, etc) from the database raises the same error. Trying to link to the tables in the database raises the same error. I am guessing...
7
13530
by: fniles | last post by:
I am using VB.Net 2003 and MS Access (connecting using OleDBConnection). I read using DataAdapter and DataSet, not DataReader. When many people try to access the database at the same time, I get the error "ExecuteReader requires an open and available Connection. The connection's current state is Open, Executing." I do not use ExecuteReader,...
0
4955
by: Salad | last post by:
A97. Split database. Frontend DB1.MDB. Backend DB1BE.MDB. Tables are linked between DB1 and DB2. From my testing, if I open DB1 exclusively using /excl the backend DB1BE is not opened exclusively. If I open DB1 but have no tables open and then open up DB1BE exclusively, DB1BE will open exclusive. But if I then attempt to open a...
0
7916
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. ...
1
7660
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...
0
7962
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...
1
5498
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...
0
5217
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...
0
3651
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...
1
2101
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
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
932
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.