473,413 Members | 2,051 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,413 software developers and data experts.

Run-Time Error -2147217904(80040e10)

I created a Database which I named "Address".
I went through the Control Panel and created a DSN to enable me connect to the Database through ODBC.

I then created a Form with the same fields as that of the Database. I wrote the necessary codes and ran the Program. Below are my codes and the runtime error I received:
Run-Time Error -2147217904(80040e10):
[Microsoft] [ODBC Microsoft Access Driver]
Too few parameters.
Expected 1


My codes:
' Stores the id of the current address
Dim intCurrAddress As Integer

' Indicates whether a change in the
' list box should invoke a save of the
' data in the text boxes
Dim intSaveUpdate As Integer

' This subroutine should be called to load or
' refresh the combo box of addresses
Private Sub LoadAddresses()

' Declare our variables
Dim dbAddress As New ADODB.Connection
Dim rsAddress As New ADODB.Recordset

' Make the connection
dbAddress.Open "dsn=address"

' Clear the combo box
cboAddresses.Clear

' Request the addresses with a SQL statement
' executed by the connection to the database
Set rsAddress = dbAddress.Execute("select * from " & _
"address order by txtLastName")

' Set the global variable to the first address
' since that is the one that will be displayed
intCurrAddress = rsAddress("idAddress")

' Loop through the addresses
Do Until rsAddress.EOF

' Add the address to the list by showing the
' persons first name and last name
cboAddresses.AddItem _
rsAddress("txtFirstName") & " " & _
rsAddress("txtLastName")

' Add the id of the address to the item data
' property for the address
cboAddresses.ItemData(cboAddresses.NewIndex) = _
rsAddress("idAddress")

' Move to the next record
rsAddress.MoveNext

Loop

' Close the DB
dbAddress.Close

' Set our save variable to indicate no saves should
' be done when the index is set
intSaveUpdate = 0

' Set to the first address
cboAddresses.ListIndex = 0

' Set back to allow updates
intSaveUpdate = 1

End Sub

' Click event of the combo box. Note that this
' is fired as well when the listindex property
' is set.
Private Sub cboAddresses_Click()

' Declare our variables
Dim dbAddress As New ADODB.Connection
Dim rsAddress As New ADODB.Recordset

' Open our connection
dbAddress.Open "dsn=address"

' Check the global variable to see if we are supposed
' to save any changes entered by the user
If intSaveUpdate = 1 Then

' Build the SQL update query
sql = "update address set " & _
"txtFirstName = '" & txtFirstName.Text & "', " & _
"txtLastName = '" & txtLastName.Text & "', " & _
"txtAddress = '" & txtAddress.Text & "', " & _
"txtCity = '" & txtCity.Text & "', " & _
"txtState = '" & txtState.Text & "', " & _
"txtZipCode = '" & txtZipCode.Text & "', " & _
"txtPhone = '" & txtPhone.Text & "', " & _
"txtFax = '" & txtFax.Text & "' where idaddress = " & intCurrAddress

' Execute the query
dbAddress.Execute sql

End If

' Set the id of the current address
intCurrAddress = cboAddresses.ItemData(cboAddresses.ListIndex)

' Build the query to retrieve the address
' data
Set rsAddress = dbAddress.Execute("select * " & _
"from address where idAddress = " & intCurrAddress)

' Display the data
lblIDAddress.Caption = rsAddress("idAddress")
txtFirstName.Text = rsAddress("txtFirstName")
txtLastName.Text = rsAddress("txtLastName")
txtAddress.Text = rsAddress("txtAddress")
txtCity.Text = rsAddress("txtCity")
txtState.Text = rsAddress("txtState")
txtZipCode.Text = rsAddress("txtZipCode")
txtPhone.Text = rsAddress("txtPhone")
txtFax.Text = rsAddress("txtFax")

' Close the database
dbAddress.Close

End Sub

' Click event of the add button
Private Sub cmdAdd_Click()

' Enable the cancel and update buttons
cmdCancel.Enabled = True
cmdUpdate.Enabled = True

' Disable the add button
cmdAdd.Enabled = False

' Disable the combo list
cboAddresses.Enabled = False

' Clear the input text boxes
lblIDAddress.Caption = ""
txtFirstName.Text = ""
txtLastName.Text = ""
txtAddress.Text = ""
txtCity.Text = ""
txtState.Text = ""
txtZipCode.Text = ""
txtPhone.Text = ""
txtFax.Text = ""

' Ensure no are done (not really possible
' since the combo box is disabled)
intSaveUpdate = 0

End Sub

' Click event of the cancel button
Private Sub cmdCancel_Click()

' Load the address into the combo box
LoadAddresses

' Enable the combo box
cboAddresses.Enabled = True

' Enable the add button
cmdAdd.Enabled = True

' Disable the update button
cmdUpdate.Enabled = False

' Diable the cancel button
cmdCancel.Enabled = False

End Sub

' Click event of the delete button
Private Sub cmdDelete_Click()

' Declare our variables
Dim dbAddress As New ADODB.Connection
Dim intResponse As Integer

' Query the user to ensure they want to
' delete the record
strResponse = MsgBox("Are you sure?", vbYesNo, "Delete Query")

' Check to see if the response was a yes
If strResponse = 6 Then

' Open the connection
dbAddress.Open "dsn=address"

' Delete the address
sql = "delete from address where idaddress = " & intCurrAddress

' Execute the SQL statement
dbAddress.Execute sql

' Load the addresses
LoadAddresses

' Close the DB
dbAddress.Close

End If

End Sub

' Click event of the Update button
Private Sub cmdUpdate_Click()

' Declare the variables
Dim dbAddress As New ADODB.Connection
Dim rsAddress As New ADODB.Recordset

' Disable the update button
cmdUpdate.Enabled = False

' Enable the add button
cmdAdd.Enabled = True

' Enable the combo boxes
cboAddresses.Enabled = True

' Open the database connection
dbAddress.Open "dsn=address"

' Build the insert SQL statement
sql = "insert into address(txtFirstName, txtLastName, txtAddress, " & _
"txtCity, txtState, txtZipCode, txtPhone, txtFax)" & _
" values('" & _
txtFirstName.Text & "', '" & _
txtLastName.Text & "', '" & _
txtAddress.Text & "', '" & _
txtCity.Text & "', '" & _
txtState.Text & "', '" & _
txtZipCode.Text & "', '" & _
txtPhone.Text & "', '" & _
txtFax.Text & "')"

' Execute the SQL statement
dbAddress.Execute sql

' Close the DB connection
dbAddress.Close

' Indicate record changes can now be saved
intSaveUpdate = 1

' Load the addresses
LoadAddresses

End Sub

Private Sub Form_Load()

' Load the addresses
LoadAddresses

End Sub

Please kindly help me examine the codes and help me detect where I am missing it.

Thank you.

Akinyemi.
Dec 29 '06 #1
1 6042
sashi
1,754 Expert 1GB
I created a Database ...
Hi there,

The error message "Too few parameters" simply means you are not passing the appropriate parameters with your SQL statement OR the tablename / fieldname used doesn't exist in the database you were trying to connect.

Double check your code once again, hope it helps. Good luck & Take care.
Dec 30 '06 #2

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

Similar topics

5
by: Bob Bamberg | last post by:
Hello All, I have been trying without luck to get some information on debugging the Runtime Error R6025 - Pure Virtual Function Call. I am working in C++ and have only one class that is derived...
0
by: Kamal Dhingra | last post by:
Hi Guys, I am developing an asp.net application .In error handling , I have 2 web.congif files ,one is in Web(which is the virtual directory) ,other i have created in a folder in Web/Admin. The...
1
by: JMCN | last post by:
hello i receive a runtime error '2465' whenever i run my module in access 97. it says 'Run-time error '2465' OOB Reports can't find the field "DuplicatePayments' referred to in your...
7
by: wmkew | last post by:
Hello everyone I'm encountering a R6002 Runtime error and several bugs when trying to generate a simple Managed C++ application with .NET 2003. The main problem seems to arise from linking with...
7
by: yuanlinjiang | last post by:
I am working on converting a win32 console application from VC6 to VC7. My version is Microsoft Development Environment 2003 version 7.1.3088. The code works fine on VC6. it is a console...
2
by: Aleksandar | last post by:
Hi, I need to convert set of Java classes exported from IBM Modeling environment to C# for implementation. When I invoke JCLA conversion from File->Open->Convert in Visual Studio 2005 it starts...
8
by: g_man | last post by:
I am trying trap Runtime error 3022 (duplicates) in the click event of a command button that closes the form. I have code in the Form_Error event that does a good job of providing a more meaningful...
7
by: John | last post by:
Hi Everyone, I'm having this extremely annoying problem with Internet Explorer 6, giving me an error message saying "unknown runtime error" whenever I try to alter the contents of a <divelement...
3
by: Jim Armstrong | last post by:
Hello all - This is driving me crazy. I have a table called tblClients - very simple, has the following fields: taxID (PK) ClientName SalesName The main form of my application allows a...
2
by: blogman | last post by:
I am getting a Visual studio 2008 IDE application R6034 runtime error. This means that the IDE application is raising the error not the application I am building. This means that Microsoft did not...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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...
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.