i have a Project and in it i have Application Form u must fill it in the internet . it have many fields to put data in , and i want to take these data to my DataBase but in many tables .
am going the Application Form with ASP.NET and the DataBase with SQL Server2000
my question is : what is the queries to enter the data in the DataBase ??????????????????

Dani AI

Generated

Short answer for : use parameterized INSERT statements inside a transaction, insert the “parent” row first, get its new identity value, then INSERT the related rows into the second table using that identity. was correct that you use INSERT (and UPDATE when changing rows) and that ASP.NET data controls can help for single-table work, but for multi-table inserts you usually handle the logic in code-behind or a stored procedure.

Example SQL pattern (replace names with your real columns/tables):

INSERT INTO Application (Name, DateOfBirth) VALUES (@Name, @DOB);
SELECT SCOPE_IDENTITY();   -- returns the new ApplicationID

INSERT INTO ApplicationDetails (ApplicationID, FieldX) VALUES (@AppID, @FieldX);

Example ADO.NET workflow in C# (concept only):

using (SqlConnection conn = new SqlConnection(connStr))
{
  conn.Open();
  using (SqlTransaction tx = conn.BeginTransaction())
  {
    SqlCommand cmd = new SqlCommand("INSERT INTO Application (...) VALUES (...); SELECT SCOPE_IDENTITY();", conn, tx);
    // add parameters...
    int appId = Convert.ToInt32(cmd.ExecuteScalar());

    SqlCommand cmd2 = new SqlCommand("INSERT INTO ApplicationDetails (ApplicationID, ...) VALUES (@AppID, ...)", conn, tx);
    // add @AppID = appId and other params...
    cmd2.ExecuteNonQuery();

    tx.Commit();
  }
}

Practical tips and cautions

  • Always use parameters (no string concatenation) to avoid SQL injection.
  • Wrap both inserts in a single transaction so a failure in the second insert rolls back the whole operation.
  • Use SCOPE_IDENTITY() instead of @@IDENTITY to reliably get the ID you just created.
  • For many child rows, run the child INSERT in a loop or call a stored procedure repeatedly; SQL Server 2000 does not support modern table-valued parameters.
  • Consider moving the logic into a stored procedure that accepts input and returns the new ID — simpler to call from ASP.NET and easier to maintain.

Start simple (a few fields) as suggested, test the identity flow, then add validation and error handling.

sorry bbut i mean
what are the quires to enter the data in the DataBase ??????

UPDATE Query always updates values in database. Also Insert Query used in ceating a table or append data to tabl. In both case easiest way to use asp.net supllied data elements like GridView,DetailsView,FormView,DataGrid etc which has wizards to guide you Bind to Table(s) of the DATABASAE. Please try from simple few fields.

ok what are the quire to 2 tables ????

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.