Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
SqlCommand comm = new SqlCommand("INSERT INTO APPLICANTDETAILS(Username,Password,Firstname,Lastname,OtherNames,dateofbirth) VALUES(@Username,@Password,@Firstname,@LastName,@OtherNames,@dateOfbirth)", conn2);


SQL
comm.Parameters.Add("@Username", SqlDbType.VarChar, 100).Value = app.Username;
            comm.Parameters.Add("@Password", SqlDbType.VarChar, 100).Value = app.Password;
            comm.Parameters.Add("@Firstname", SqlDbType.VarChar, 100).Value = app.FirstName;
            comm.Parameters.Add("@LastName", SqlDbType.VarChar, 100).Value = app.LastName;
            comm.Parameters.Add("@OtherNames", SqlDbType.VarChar, 100).Value = app.OtherNames;
            comm.Parameters.Add("@dateOfBirth",SqlDbType.VarChar,50).Value = app.DateOfBirth;

C#
try
            {
                comm.Connection.Open();
                comm.ExecuteNonQuery();
                
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                comm.Connection.Close();
            }
Posted

1 solution

you can also pass the value directly....
for ex. textbox1.text
this type of "@Firstname" use in the store procedure approch
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900