invalid column usrname1 was the error foru update() can some one suggest

Last post 08-13-2008 2:48 PM by arun velagapalli. 3 replies.

Sort Posts:

  • invalid column usrname1 was the error foru update() can some one suggest

    08-08-2008, 3:59 PM

     

    protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
        {
            TextBox TextBox1 = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName");


            Session["usrnm"] = TextBox1.Text.ToString();
            Label1.Text = Session["usrnm"].ToString();


            Label2.Text = Session["phone"].ToString();
          
        }
        
         
       
       
        protected void CreateUserWizard1_ContinueButtonClick(object sender, EventArgs e)
        {
            
            SqlDataSource1.Update();
            Response.Redirect("default.aspx");
        }
    Filed under:
  • Re: invalid column usrname1 was the error foru update() can some one suggest

    08-08-2008, 4:17 PM

    code behind for update

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                SelectCommand="SELECT * FROM [amsa_mem]" UpdateCommand="UPDATE amsa_mem SET MEM_FNAME =fname, MEM_LNAME =lname, MEM_MNAME =mname, MEM_ADDR =addr, MEM_DES =dest, MEM_EMAIL =email, MEM_PHONE =phone, MEM_CITY =city, MEM_STATE =state, MEM_ZIP =zip, MEM_FAX =fax WHERE amsa_mem.UserName=usrname1">
                <UpdateParameters>
                     <asp:SessionParameter Name="fname" SessionField="fname" />
                      <asp:SessionParameter Name="lname" SessionField="lname" />
                      <asp:SessionParameter Name="mname" SessionField="manme" />
                      <asp:SessionParameter Name="addr" SessionField="addr" />
                      <asp:SessionParameter Name="dest" SessionField="dest" />
                      <asp:SessionParameter Name="email" SessionField="email" />
                      <asp:SessionParameter Name="phone" SessionField="phone" />
                      <asp:SessionParameter Name="city" SessionField="city" />
                      <asp:SessionParameter Name="state" SessionField="state" />
                      <asp:SessionParameter Name="zip" SessionField="zip" />
                      <asp:SessionParameter Name="fax" SessionField="fax" />
                    <asp:FormParameter Name ="usrname1" FormField="Label1" />
                </UpdateParameters>
            </asp:SqlDataSource>

     

  • Re: invalid column usrname1 was the error foru update() can some one suggest

    08-13-2008, 3:52 AM
    Answer

    arun velagapalli:
    <asp:FormParameter Name ="usrname1" FormField="Label1" />
     

    Hi friend,

    It seems that you do not know the correct way to use 'asp:FormParament' , here is an artilce will show you the right way,

    http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.formparameter.aspx


          <asp:sqldatasource
            id="SqlDataSource1"
            runat="server"
            connectionstring="<%$ ConnectionStrings:MyNorthwind %>"
            selectcommand="SELECT CompanyName,ShipperID FROM Shippers"
            insertcommand="INSERT INTO Shippers (CompanyName,Phone) VALUES (@CoName,@Phone)">
              <insertparameters>
                <asp:formparameter name="CoName" formfield="CompanyNameBox" />
                <asp:formparameter name="Phone"  formfield="PhoneBox" />
              </insertparameters>
          </asp:sqldatasource>
    
          <br /><asp:textbox
               id="CompanyNameBox"
               runat="server" />
    
          <asp:RequiredFieldValidator
            id="RequiredFieldValidator1"
            runat="server"
            ControlToValidate="CompanyNameBox"
            Display="Static"
            ErrorMessage="Please enter a company name." />
    
          <br /><asp:textbox
               id="PhoneBox"
               runat="server" />
    
          <asp:RequiredFieldValidator
            id="RequiredFieldValidator2"
            runat="server"
            ControlToValidate="PhoneBox"
            Display="Static"
            ErrorMessage="Please enter a phone number." />  

    and please attention more on the following lines,

    1. insertcommand="INSERT INTO Shippers (CompanyName,Phone) VALUES (@CoName,@Phone)"> 
    2. <asp:formparameter name="CoName" formfield="CompanyNameBox" />
    3. <asp:textbox id="CompanyNameBox"  runat="server" />
    Line 1 tell us that the command need two parameters, they are "CoName" and "Phone";
    Line 2 tell us that parameter of "CoName" will bind to a web control which the ID is assigned  "CompanyhNameBox" ;
    Line 3 tell us that parameter bind control is a TextBox control. 


     
     

     

     

    Sincerely,
    Ocean
    Microsoft Online Community Support
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as
    Answer” if a marked post does not actually answer your question.
  • Re: invalid column usrname1 was the error foru update() can some one suggest

    08-13-2008, 2:48 PM

     Thanks everyone, there was little misconception for '@' symbol in sql update ... that was the problem and worked it out

Page 1 of 1 (4 items)
Microsoft Communities
Page view counter