Re: Parameter problem..help is needed please

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Michael C# (xyz_at_abcdef.com)
Date: 02/27/05


Date: Sun, 27 Feb 2005 14:34:18 -0500

I think you need to add a size to your .Add() function, like this:

oleAdapter.SelectCommand.Parameters.Add("@BizName", OleDbType.VarChar, 50)

I used a default of 50, because that's what Access defaults to for those
type fields, but you should change it to match the size of the field in your
database.

Same thing with the @BizAddress parameter.

Thx,
Mike C.

"Nab" <Nab@discussions.microsoft.com> wrote in message
news:51A57F18-B570-4311-859C-3A0B7357FC6C@microsoft.com...
> Can someone please help identify where the problem exist in this code. A
> connection with an Access database (in this case)is established through
> the
> GUI. The snippet of code is aimed to implement two parameters: an input
> parameter and an output parameter. The user inputs a value in textbox1 to
> serve as input for parameter @BizName. The output parameter is
> @BizAddress.
> It's value is captured in variable i and placed in textbox2.
>
> Why do I get this error message:
> Server Error in '/WebApplicationAccessParam' Application.
>
> Parameter 1: '@BizAddress' of type: String, the property Size has an
> invalid
> size: 0
>
> This is the code:
>
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> Dim i As String
>
> Dim dsResult As New DataSet
> Dim strSQL As String
> strSQL = "SELECT @BizAddress=Address FROM testTable WHERE Name =
> @BizName"
> Dim oleAdapter As New OleDbDataAdapter(strSQL, OleDbConnection1)
> oleAdapter.SelectCommand.Parameters.Add("@BizName",
> OleDbType.VarChar)
> oleAdapter.SelectCommand.Parameters("@BizName").Direction =
> ParameterDirection.Input
> oleAdapter.SelectCommand.Parameters("@BizName").Value =
> TextBox1.Text
>
> oleAdapter.SelectCommand.Parameters.Add("@BizAddress",
> OleDbType.VarChar)
> oleAdapter.SelectCommand.Parameters("@BizAddress").Direction =
> ParameterDirection.Output
> i = oleAdapter.SelectCommand.Parameters("@BizAddress").Value
>
> TextBox2.Text = i
>
>
> oleAdapter.Fill(dsResult, "testTable")
> DataGrid1.DataSource = dsResult
> DataGrid1.DataMember = "testTable"
> DataGrid1.DataBind()
> OleDbConnection1.Close()
>
>
>
> Many thanks in advance.
>
>
>



Relevant Pages

  • Problem Connecting To Access Database
    ... an Access database. ... All of the apps were working fine on the web server. ... the same error message for all of them. ... RaisePostBackEvent(String eventArgument) ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Procedure too large
    ... I am trying to set the controlsource property for a textbox1 on a ... userform1. ... Private Sub UserForm1_Initialize ... manually but I am getting a "Invalid property value" error message. ...
    (microsoft.public.excel.programming)
  • Re: Operation must use an updateable query
    ... Access database. ... > settings are not correcting the problem for me. ... > I am developing on WinXP machine using ASP VBScript and Access 2003. ... > Here's a sampling of the code which the error message seems to reference: ...
    (microsoft.public.data.ado)
  • Re: CommandEnabled Error Message
    ... I don't how to split up access database. ... which windows security updates ... I have encountered an error message of CommandEnabled expression when open ... I have used Spreadsheet 11.0 by Office Web Component. ...
    (microsoft.public.access.modulesdaovba)
  • Parameter problem..help is needed please
    ... The snippet of code is aimed to implement two parameters: ... The user inputs a value in textbox1 to ... Why do I get this error message: ...
    (microsoft.public.sqlserver.programming)