Advertisement

09.04.2007 at 03:14PM PDT, ID: 22806693
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.4

Parameterized INSERT query in Jet/DAO/VB6 using QueryDef

Asked by adg in Microsoft Access Database, Visual Basic Programming, VB Database Programming

Tags: , , ,

I have been using parameterized queries (using QueryDef objects against a 2.x database using DAO 3.6) extensively for queries, updates, and deletions. However, I ran into a case where I could not do a parameterized insertion of a zero-length string. For example, the following code does not work (it inserts NULL):

----
Dim oQD as QueryDef
Set oQD = oDB.CreateQueryDef("", "parameters sData string;" & _
        " insert into whatever ( fldx ) values ( [sData] )")
oQD.Parameters!sData = ""
oQD.Execute dbFailOnError
----

[oDB is a class level variable of type Database - again, using DAO 3.6 against a Jet 2.x MDB]

While investigating, I added a watch on oQD. The type of the field is dbString, and "AllowZeroLength" is true. At first, "Required" was false, but I tried again after setting it to true as well, but it had no effect.

As you can see, I am explicitly storing a zero length string ("") into the sData parameter, but it stores null in the table. I have even checked the value of "oQD.Parameters!sData" and the debugger tip shows null AFTER storing "" to it. I have checked the type of the parameter and it is a string parameter. Does anyone know how to store a parameterized empty string using a QueryDef? I don't want to store a space or anything stupid like that because the table is going to have an EXTREME record count (2 million+) - I can't afford to waste any space. I have to avoid storing null because other team members code is not handling null correctly and crashing with "Invalid use of null" and it would be counterproductive to demand changes to established code.

I have tried replacing [sData] in the querydef with """" (a pair of double-quotes) and it DOES work - it stores a zero length string. I need to know because I won't always be storing an empty string.

Thanks!
Start Free Trial
 
Loading Advertisement...
 
[+][-]09.04.2007 at 04:01PM PDT, ID: 19829088

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.04.2007 at 04:05PM PDT, ID: 19829099

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.04.2007 at 04:24PM PDT, ID: 19829167

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.04.2007 at 04:34PM PDT, ID: 19829210

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.04.2007 at 09:03PM PDT, ID: 19829935

View this solution now by starting your 14-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Access Database, Visual Basic Programming, VB Database Programming
Tags: insert, query, dao, parameterized
Sign Up Now!
Solution Provided By: LPurvis
Participating Experts: 3
Solution Grade: A
 
 
[+][-]09.04.2007 at 09:55PM PDT, ID: 19830048

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.05.2007 at 09:12AM PDT, ID: 19833580

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.05.2007 at 03:21PM PDT, ID: 19836217

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.05.2007 at 03:43PM PDT, ID: 19836325

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.05.2007 at 09:20PM PDT, ID: 19837604

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-43 / EE_QW_1_20070628