473,396 Members | 1,935 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,396 software developers and data experts.

object not defined/odbc with msaccess

hi

i 'm writng a code using msaccess with odbc.
my dsn name is htgry
i want to insert data eneterd in text fields to a table named qwer on clicking a command button.

code as follows

Private Sub Command14_Click()


Dim dbLocation 'Location of our Access database file
Dim sSQL 'Our SQL query

dbLocation = "C:\Documents and Settings\Administrator\Desktop"
Set objADO = dbLocation.CreateObject("ADODB.Connection") 'Create an ADO connection to a database //// line1

objADO.Open "htgry" //// line2
objADO.Open dbLocation 'Open the database
sSQL = "INSERT INTO qwer ( name , amount ) VALUES('" & Text7 & "' , '" & Text9 & "')" 'Set our SQL query
objADO.Execute (sSQL) 'Execute this SQL query


objADO.Close
Set objADO = Nothing

End Sub

it is not being executed and error is "object not defined " at line 1 and line 2

kindly make me complete this programme error free.
with anticipation
Nov 24 '06 #1
6 2319
MMcCarthy
14,534 Expert Mod 8TB
The syntax for creating DSN connections is as follows:
Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. Dim conConnector As ADODB.Connection
  4.  
  5.     Set conConnector = New ADODB.Connection
  6.  
  7.     conConnector.Open "DSN=htgry;UID=UserName;PWD=Password;"
  8.  
  9.     conConnector.Close
  10.     Set conConnector = Nothing
  11.  
  12.  
  13.  
Nov 25 '06 #2
ihav euse dyour code
following error occured
run time error 2147467259(80004005)
[Microsoft]ODBC microsoft access driver] the database has been placed in a state by an unknown user that prevents it from being opened or locked
dsn
code:

Dim dbLocation 'Location of our Access database file
Dim sSQL 'Our SQL query
Dim conConnector As ADODB.Connection

Set conConnector = New ADODB.Connection

conConnector.Open "DSN=htgry;UID=UserName;PWD=Password;"
dbLocation = "C:\Documents and Settings\Administrator\Desktop\dbd"
conConnector.Open dbLocation
sSQL = "INSERT INTO Table1 ( name , amount ) VALUES('" & Text7 & "' , '" & Text9 & "')" 'Set our SQL query
conConnector.Execute (sSQL) 'Execute this SQL query
conConnector.Close
Set conConnector = Nothing

what is password, userid?
hoping reply



The syntax for creating DSN connections is as follows:
Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. Dim conConnector As ADODB.Connection
  4.  
  5.     Set conConnector = New ADODB.Connection
  6.  
  7.     conConnector.Open "DSN=htgry;UID=UserName;PWD=Password;"
  8.  
  9.     conConnector.Close
  10.     Set conConnector = Nothing
  11.  
  12.  
  13.  
Nov 27 '06 #3
ihav euse dyour code
following error occured
run time error 2147467259(80004005)
[Microsoft]ODBC microsoft access driver] the database has been placed in a state by an unknown user that prevents it from being opened or locked
dsn htgry, filename dbd, table name Table1.
code:

Dim dbLocation 'Location of our Access database file
Dim sSQL 'Our SQL query
Dim conConnector As ADODB.Connection

Set conConnector = New ADODB.Connection

conConnector.Open "DSN=htgry;UID=UserName;PWD=Password;"
dbLocation = "C:\Documents and Settings\Administrator\Desktop\dbd"
conConnector.Open dbLocation
sSQL = "INSERT INTO Table1 ( name , amount ) VALUES('" & Text7 & "' , '" & Text9 & "')" 'Set our SQL query
conConnector.Execute (sSQL) 'Execute this SQL query
conConnector.Close
Set conConnector = Nothing

what is password, userid?
hoping reply



The syntax for creating DSN connections is as follows:
Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. Dim conConnector As ADODB.Connection
  4.  
  5.     Set conConnector = New ADODB.Connection
  6.  
  7.     conConnector.Open "DSN=htgry;UID=UserName;PWD=Password;"
  8.  
  9.     conConnector.Close
  10.     Set conConnector = Nothing
  11.  
  12.  
  13.  
Nov 27 '06 #4
MMcCarthy
14,534 Expert Mod 8TB
You said you created a DSN to another database. Does that database have a userid and password? If not then just put "DSN=htgry;"
Nov 27 '06 #5
hello

i used ur code
error: not a valid password
wat is password and how to overcome this error

pls reply

The syntax for creating DSN connections is as follows:
Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. Dim conConnector As ADODB.Connection
  4.  
  5.     Set conConnector = New ADODB.Connection
  6.  
  7.     conConnector.Open "DSN=htgry;UID=UserName;PWD=Password;"
  8.  
  9.     conConnector.Close
  10.     Set conConnector = Nothing
  11.  
  12.  
  13.  
Dec 8 '06 #6
NeoPa
32,556 Expert Mod 16PB
hello

i used ur code
error: not a valid password
wat is password and how to overcome this error

pls reply
It sounds like you need to have a word with your IT department.
Ask them to explain this concept to you and give you the details you need to access via this DSN.
Dec 8 '06 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Kong Li | last post by:
Follow up to this thread, the latest Oracle 9i release 2 patchset (9.2.0.5) fixed the handle count leak problem. The problem is in Oracle client component. Thanks. Kong ----- From: Kong...
0
by: Fatt Shin | last post by:
Hi, I'm running MySQL 4.0.13, connecting from PowerBuilder 9 using ODCB Connector 3.51. I'm facing a problem where whenever I issue a SELECT COUNT(*) statement from PowerBuilder, I always get SQL...
1
by: David Codding | last post by:
I am using ODBC 4.51 and mySQL 4.0.1-NT. I have an app that is written in vb6 with msAccess 2000 that was converted to mySQL. Everything is working great except for one thing. I have a grid...
2
by: Len Kowalik | last post by:
MSAccess 2000, SQL-Server 97 I am getting a permission denied response from an attempt to execute a stored proc, which has public access revoked and app role access, on the last statement of the...
6
by: Andi Reisenhofer | last post by:
Hallo C# folks, Somebody know how to create a ODBC DSN dynamically in c# program. Also interesting for me would be the connectionstring for an Access Database. Thinks a lot Andreas
0
by: Lewt | last post by:
I am aware of the 'hack the registry' approach. This is just not a safe way to accomplish this on a user's PC. I need to do this the right way. Is there anyone -perhaps from Microsoft - out there...
2
by: mvl_groups_user | last post by:
I am trying to look up data on about 1000 records from a 6 million record view on a DB2 database using msaccess. The 6 million record DB2 view is connected through a linked ODBC table (table A),...
0
by: Sweden | last post by:
We would like to create an ODBC link or OLEDB link using MsAccess.Mdb to obtain individual table details from Accpac Plus in Dos (an accounting program)? The database has Modules such as AP, AR...
4
by: Rodent | last post by:
I have an IIS 6.0, 2003 Server running with PHP installed. I have an access database with a DSN ODBC connection configured. When this ODBC is configured to access the database locally - great,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
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
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...

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.