You must Sign In to post a response.
  • Category: ASP.NET

    Inserting register data into two table by checking condition

    Hi
    i am trying to insert register details in two tables. i am using one guid pin no, with that pin number i am checking condition to insert into the second table. but i am getting an error like invalid syntax or invalid column name, i am using nvarchar datatype to store guid in my first table dat is for pin number collumn.
  • #761888

    Hi

    invalid column name means

    Check your table you have mention column is have or not in the table then both side put same datatype thats better for retrieve and stored purpose in your table from the c# server side code.


    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #761889

    Hi

    You can follow this steps you can achieve your output


    Create Table One
    (
    PINNO nvarchar(30)
    )

    Create Table Two
    (
    PINNO nvarchar(30)
    )




    You can try this code for c#


    protected void btsubmit_Click(object sender, EventArgs e)
    {
    DataTable dt = new DataTable();
    SqlDataAdapter sqladp = new SqlDataAdapter("Select PINNO from one where PINNO="+ GID +"", con);
    sqladp.Fill(dt);

    if (dt.Rows.Count > 0)
    {
    SqlCommand sqlcmd = new SqlCommand("Insert into two values('"+ GID +"')", con);
    sqlcmd.ExecuteNonQuery();
    }
    }


    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #761903

    I think you are passing the invalid data while inserting


    By Nathan
    Direction is important than speed

  • #761908
    thanx 2 all for ur respond n ur answer r really helpul for me...once again thankk u all


Sign In to post your comments