Re: Parameter problem..help is needed please
From: Michael C# (xyz_at_abcdef.com)
Date: 02/27/05
- Next message: Michael C#: "Re: SQL Query Question"
- Previous message: Aaron: "recreate index"
- In reply to: Nab: "Parameter problem..help is needed please"
- Messages sorted by: [ date ] [ thread ]
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.
>
>
>
- Next message: Michael C#: "Re: SQL Query Question"
- Previous message: Aaron: "recreate index"
- In reply to: Nab: "Parameter problem..help is needed please"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|