Must declare the scalar variable '@FirstName'

Discussion in 'ASP .Net' started by =?Utf-8?B?S2VuIEFkZW5pamk=?=, Apr 26, 2005.

  1. Must declare the scalar variable '@FirstName'

    ContactGridViewWebForm.aspx
    <aspqlDataSource
    RunAt="server"
    ID="SqlDataSourceContact"

    ConnectionString="server=localhost;database=WordEngineering;Integrated
    Security=SSPI;"
    ProviderName="System.Data.OleDb"
    SelectCommand="SELECT SequenceOrderId, FirstName, LastName,
    OtherName, Company FROM Contact ORDER BY SequenceOrderId"
    UpdateCommand="UPDATE Contact SET FirstName=@FirstName,
    LastName=@LastName, Company=@Company WHERE equenceOrderId=@SequenceOrderId"
    href="mailtoequenceOrderId=@SequenceOrderId">SequenceOrderId=@SequenceOrderId"
    />

    <asp:GridView
    RunAt="server"
    ID="GridViewContact"
    AutoGenerateColumns=false
    AutoGenerateEditButton=true
    DataKeyField="SequenceOrderId"
    AllowPaging="true"
    AllowSorting="true"
    >


    ContactGridViewPage.aspx.cs
    public string DatabaseConnectionString = "Provider=SQLOLEDB;Data
    Source=localhost;Integrated Security=SSPI;Initial Catalog=WordEngineering;";
    SqlDataSourceContact.ConnectionString = DatabaseConnectionString;
    GridViewContact.DataSourceID = SqlDataSourceContact.ID;
     
    =?Utf-8?B?S2VuIEFkZW5pamk=?=, Apr 26, 2005
    #1
    1. Advertising

  2. Take a look at your code. Do you see the string "@FirstName" anywhere?

    Do you know what it is?

    It's a parameter decaration. Where have you defined the parameter?

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    What You Seek Is What You Get.

    "Ken Adeniji" <> wrote in message
    news:D...
    > Must declare the scalar variable '@FirstName'
    >
    > ContactGridViewWebForm.aspx
    > <aspqlDataSource
    > RunAt="server"
    > ID="SqlDataSourceContact"
    >
    > ConnectionString="server=localhost;database=WordEngineering;Integrated
    > Security=SSPI;"
    > ProviderName="System.Data.OleDb"
    > SelectCommand="SELECT SequenceOrderId, FirstName, LastName,
    > OtherName, Company FROM Contact ORDER BY SequenceOrderId"
    > UpdateCommand="UPDATE Contact SET FirstName=@FirstName,
    > LastName=@LastName, Company=@Company WHERE
    > equenceOrderId=@SequenceOrderId"
    > href="mailtoequenceOrderId=@SequenceOrderId">SequenceOrderId=@SequenceOrderId"
    > />
    >
    > <asp:GridView
    > RunAt="server"
    > ID="GridViewContact"
    > AutoGenerateColumns=false
    > AutoGenerateEditButton=true
    > DataKeyField="SequenceOrderId"
    > AllowPaging="true"
    > AllowSorting="true"
    > >

    >
    > ContactGridViewPage.aspx.cs
    > public string DatabaseConnectionString = "Provider=SQLOLEDB;Data
    > Source=localhost;Integrated Security=SSPI;Initial
    > Catalog=WordEngineering;";
    > SqlDataSourceContact.ConnectionString = DatabaseConnectionString;
    > GridViewContact.DataSourceID = SqlDataSourceContact.ID;
     
    Kevin Spencer, Apr 26, 2005
    #2
    1. Advertising

  3. Must declare the scalar variable '@FirstName' occurs when the user concludes
    the edit mode by clicking the update button.

    In the past, efforts to define the parameter have been unsuccessful, but
    could you please share a working sample code example.

    Thank you.

    "Kevin Spencer" wrote:

    > Take a look at your code. Do you see the string "@FirstName" anywhere?
    >
    > Do you know what it is?
    >
    > It's a parameter decaration. Where have you defined the parameter?
    >
    > --
    > HTH,
    >
    > Kevin Spencer
    > Microsoft MVP
    > ..Net Developer
    > What You Seek Is What You Get.
    >
    > "Ken Adeniji" <> wrote in message
    > news:D...
    > > Must declare the scalar variable '@FirstName'
    > >
    > > ContactGridViewWebForm.aspx
    > > <aspqlDataSource
    > > RunAt="server"
    > > ID="SqlDataSourceContact"
    > >
    > > ConnectionString="server=localhost;database=WordEngineering;Integrated
    > > Security=SSPI;"
    > > ProviderName="System.Data.OleDb"
    > > SelectCommand="SELECT SequenceOrderId, FirstName, LastName,
    > > OtherName, Company FROM Contact ORDER BY SequenceOrderId"
    > > UpdateCommand="UPDATE Contact SET FirstName=@FirstName,
    > > LastName=@LastName, Company=@Company WHERE
    > > equenceOrderId=@SequenceOrderId"
    > > href="mailtoequenceOrderId=@SequenceOrderId">SequenceOrderId=@SequenceOrderId"
    > > />
    > >
    > > <asp:GridView
    > > RunAt="server"
    > > ID="GridViewContact"
    > > AutoGenerateColumns=false
    > > AutoGenerateEditButton=true
    > > DataKeyField="SequenceOrderId"
    > > AllowPaging="true"
    > > AllowSorting="true"
    > > >

    > >
    > > ContactGridViewPage.aspx.cs
    > > public string DatabaseConnectionString = "Provider=SQLOLEDB;Data
    > > Source=localhost;Integrated Security=SSPI;Initial
    > > Catalog=WordEngineering;";
    > > SqlDataSourceContact.ConnectionString = DatabaseConnectionString;
    > > GridViewContact.DataSourceID = SqlDataSourceContact.ID;

    >
    >
    >
     
    =?Utf-8?B?S2VuIEFkZW5pamk=?=, Apr 26, 2005
    #3
  4. No problemo. But you must promise to read the WHOLE thing! ;-)

    http://msdn.microsoft.com/library/d...tasqlclientsqlcommandclassparameterstopic.asp

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    What You Seek Is What You Get.

    "Ken Adeniji" <> wrote in message
    news:...
    > Must declare the scalar variable '@FirstName' occurs when the user
    > concludes
    > the edit mode by clicking the update button.
    >
    > In the past, efforts to define the parameter have been unsuccessful, but
    > could you please share a working sample code example.
    >
    > Thank you.
    >
    > "Kevin Spencer" wrote:
    >
    >> Take a look at your code. Do you see the string "@FirstName" anywhere?
    >>
    >> Do you know what it is?
    >>
    >> It's a parameter decaration. Where have you defined the parameter?
    >>
    >> --
    >> HTH,
    >>
    >> Kevin Spencer
    >> Microsoft MVP
    >> ..Net Developer
    >> What You Seek Is What You Get.
    >>
    >> "Ken Adeniji" <> wrote in message
    >> news:D...
    >> > Must declare the scalar variable '@FirstName'
    >> >
    >> > ContactGridViewWebForm.aspx
    >> > <aspqlDataSource
    >> > RunAt="server"
    >> > ID="SqlDataSourceContact"
    >> >
    >> > ConnectionString="server=localhost;database=WordEngineering;Integrated
    >> > Security=SSPI;"
    >> > ProviderName="System.Data.OleDb"
    >> > SelectCommand="SELECT SequenceOrderId, FirstName, LastName,
    >> > OtherName, Company FROM Contact ORDER BY SequenceOrderId"
    >> > UpdateCommand="UPDATE Contact SET FirstName=@FirstName,
    >> > LastName=@LastName, Company=@Company WHERE
    >> > equenceOrderId=@SequenceOrderId"
    >> > href="mailtoequenceOrderId=@SequenceOrderId">SequenceOrderId=@SequenceOrderId"
    >> > />
    >> >
    >> > <asp:GridView
    >> > RunAt="server"
    >> > ID="GridViewContact"
    >> > AutoGenerateColumns=false
    >> > AutoGenerateEditButton=true
    >> > DataKeyField="SequenceOrderId"
    >> > AllowPaging="true"
    >> > AllowSorting="true"
    >> > >
    >> >
    >> > ContactGridViewPage.aspx.cs
    >> > public string DatabaseConnectionString = "Provider=SQLOLEDB;Data
    >> > Source=localhost;Integrated Security=SSPI;Initial
    >> > Catalog=WordEngineering;";
    >> > SqlDataSourceContact.ConnectionString = DatabaseConnectionString;
    >> > GridViewContact.DataSourceID = SqlDataSourceContact.ID;

    >>
    >>
    >>
     
    Kevin Spencer, Apr 26, 2005
    #4
  5. =?Utf-8?B?S2VuIEFkZW5pamk=?=

    leojose

    Joined:
    Aug 17, 2007
    Messages:
    1
    Just declare DataKeyNames="slno" in the GridView property. It will fix the issue. Thanks.
     
    leojose, Aug 17, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jiggaz
    Replies:
    6
    Views:
    32,219
    Raghudubba
    Nov 5, 2009
  2. Oded Dror

    Must Declare the Scalar Variable error

    Oded Dror, May 28, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    19,053
    Oded Dror
    May 28, 2006
  3. Replies:
    0
    Views:
    2,487
  4. Mark
    Replies:
    1
    Views:
    1,544
  5. Ken Adeniji

    Must declare the scalar variable '@FirstName'

    Ken Adeniji, Apr 26, 2005, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    131
    Ken Adeniji
    Apr 26, 2005
Loading...

Share This Page