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

Passing parameters to action stored procedures using ADO, in Access Project

There is a form in an Access Project (.adp, Access front end with SQL
Server) for entering data into a table for temporary storing. Then, by
clicking a botton, several action stored procedures (update, append) should
be activated in order to transfer data to other tables.

I tried to avoid any coding in VB, as I am not a professional, but I have
found a statement in an article, that, unlike select queries, form's Input
Property can't be used for action queries. Therefore, parameters can be
passed to action stored procedure only by using ADO through VB.

As I'm not very familiar with VB, I had to search in literature.

So, this is a solution based on creating Parameter object in ADO and then
appending values to Parameter collection.

Please, consider the following procedure I created for passing parameters
from form's control objects (Text boxes) to a stored procedure
DTKB_MB_UPDATE:

Private Sub Command73_Click()

Dim cmd As ADODB.Command

Set cmd = New ADODB.Command

cmd.ActiveConnection = CurrentProject.Connection

cmd.CommandText = "DTKB_MB_UPDATE"

cmd.CommandType = adCmdStoredProc

Dim par As ADODB.Parameter

Set par = cmd.CreateParameter("@DATE", adDBTimeStamp, adParamInput)

cmd.Parameters.Append par

Set par = cmd.CreateParameter("@BATCH_NUMBER", adVarWChar, adParamInput, 50)

cmd.Parameters.Append par

Set par = cmd.CreateParameter("@STATUS", adVarWChar, adParamInput, 50)

cmd.Parameters.Append par

Set par = cmd.CreateParameter("@DEPARTMENT", adVarWChar, adParamInput, 50)

cmd.Parameters.Append par

Set par = cmd.CreateParameter("@PRODUCTION", adVarWChar, adParamInput, 50)

cmd.Parameters.Append par

Set par = cmd.CreateParameter("@SAMPLING_TYPE", adVarWChar, adParamInput,
50)

cmd.Parameters.Append par

cmd.Parameters("@DATE") = Me.DATE

cmd.Parameters("@BATCH_NUMBER") = Me.BATCH_NUMBER

cmd.Parameters("@STATUS") = Me.STATUS

cmd.Parameters("@DEPARTMENT") = Me.DEPARTMENT

cmd.Parameters("@PRODUCTION") = Me.PRODUCTION

cmd.Parameters("@SAMPLING_TYPE") = Me.SAMPLING_TYPE

cmd.Execute

Set cmd = Nothing

End Sub

Unfortunately, when clicking on the botton, the following error apears:

"Run-time error'-2147217913 (80040e07)':Syntax error converting datetime
from character string."

Obviously, there is some problem regarding parameter @DATE. In SQL Server it
is datetime, on the form's onbound text box it is short date (dd.mm.yyyy)
data type. I have found in literature that in ADO it should be
adDBTimeStamp.

So, what is the problem ?

Greetings,

Zlatko
Nov 13 '05 #1
1 2395
Please do not post the same question to many groups.

You lose out by the fragmentation of replies.

Those who could answer your question may not bother.

If you believe that your question validly requires posting to multiple
places, you could make a single post to the groups, so follow ups also make
it to the different groups.
Nov 13 '05 #2

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

Similar topics

3
by: Hursh | last post by:
Hi, I have written some stored procedures in SQL and these procedures return some value. I want these values to be captured by the ASP code. I am able to access the tables using ADO(...
3
by: WGW | last post by:
Though I am a novice to MS SQL server (2000 I believe), I can do almost! everything I need. Maybe not efficiently, but usefully. However, I have a problem -- a complex query problem... I can...
1
by: zlatko | last post by:
I use a stored procedure that is calling several other stored procedure which update or append values in several tables. All of them are stored procedures with input parameters by which they filter...
2
by: zlatko | last post by:
There is a form in an Access Project (.adp, Access front end with SQL Server) for entering data into a table for temporary storing. Then, by clicking a botton, several action stored procedures...
1
by: tdlogger | last post by:
Help! I’m running ado.net using sql7 with service pack 4. I’m trying to use stored procedures. When I try passing varchar type parameters it comes back with 0 transactions. If I pass int...
6
by: dharmadam | last post by:
Is it possible to pass a column name or the order of the column name in the DB2 table table function. For example, I want to update the address of a person by passing one of the address column name...
3
by: Lauren Quantrell | last post by:
I am feeling a little overwhelmed trying to get my MDB-ADP conversion going. The first thing I need to figure out (very quickly) is how to use the values of unbound controls of forms in Stored...
3
by: Zlatko | last post by:
A question concerning Access Project with SQL Server: I use a stored procedure that is calling several other stored procedure which update or append values in several tables. All of them are...
7
by: Zlatko Matiæ | last post by:
Let's assume that we have a database on some SQL server (let it be MS SQL Server) and that we want to execute some parameterized query as a pass.through query. How can we pass parameters to the...
9
by: weirdwoolly | last post by:
Hopefully someone will be able to help. I have written a stored procedure in C++ called from a Java test harness to validate the graphic data types in C++ and their use. I have declared the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.