Re: Error "no value given for one or more required parameters"



On Thu, 13 Oct 2005 21:59:48 -0700, JohnC wrote:

>I just could not figure out what is wrong or missing - here my sample code:
>
> Dim horse_recordset As New ADODB.Recordset
> Dim SQLstmt As String
> Dim xyz As Integer
>
> xyz = 13
>
> SQLstmt = "SELECT [Horse-ID], [Horse Name], [Registration Nummer],
>[Breed] FROM Horses WHERE (Horses.[Horse-ID] = xyz);"
>
> horse_recordset.Open SQLstmt, CurrentProject.Connection,
>adOpenForwardOnly, adLockReadOnly
>
>Regardless of what I have tried I always get the same error - if I enter a
>specific value in the query for ex. I "hard-code" 13 into the query instead
>of xyz the query runs with no error - therefore it must have something to do
>the way I use or declare the variable xyz or the syntax.
>
>PLEASE HELP!!!!

Hi John,

Try this one instead:

SQLstmt = "SELECT [Horse-ID], [Horse Name], [Registration Nummer],
[Breed] FROM Horses WHERE (Horses.[Horse-ID] = " & xyz & ");"

By the way, you posted this to the .mseq group, which is actually
intended for support of Microsoft English Query. Your code looks like VB
calling SQL Server. You might get more and better replies in either one
of the VB groups, or in microsoft.public.sqlserver.programming.

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
.



Relevant Pages

  • RE: Uploading a Picture
    ... List Disk Drives ... The following sample code uses a StreamReader class to read the System.ini ... Dim ... End Sub ...
    (microsoft.public.vb.database)
  • RE: Pass listbox values to autofilter
    ... I have some sample code which might help you get where you want to go. ... 'Setting criteria on multiple column filters ... Dim numFilt1 As Single ... Dim strFilt1 As String ...
    (microsoft.public.excel.programming)
  • RE: UDT in an Add-in
    ... also contains another module containing a single UDF that makes use of a UDT. ... interpolation within a given ... Dim iErrNum As BezErr ... Function CreateXYZ(a, b, Optional c) As XYZ ...
    (microsoft.public.excel.programming)
  • RE: Window object in Word 2007
    ... I also get your sample code to work, but my application is a little more ... Dim testDoc As Object ... Set wrdApp = CreateObject ... You can send feedback directly to my manager at: ...
    (microsoft.public.office.developer.com.add_ins)
  • Re: How to "set" the PixelFormat for a bitmap?
    ... that sample code was in C#. in VB... ... Dim bm as new Bitmap(org.Width, org.Height <,optional pixel format>) ... 'continue to draw on g here to add text or graphics. ...
    (microsoft.public.dotnet.languages.vb)