Hello friends 
Here in the first void i am adding value to database by using storeprocedure.

In the second void same thing i am trying to do, 
but i dont want to use any  storeprocedure, directly i am trying to add value 
....that's  not happening 
can u pls give me proper solution.
Using SqlClient ...not OleDb.

1st
***
private void cmd_add_Click(object sender, System.EventArgs e)
  {
   myconnection conClass = new myconnection();
   conClass.openConnection(); 
   try
   {
    string strsql;
    strsql = "sp_addDotnet"; //name of the storeProcedure
    SqlCommand sqlCom = new SqlCommand(strsql, conClass.mysqlconn);
              sqlCom.CommandType = CommandType.StoredProcedure;

    sqlCom.Parameters.Add(new SqlParameter("@fName",(textBox2.Text)));
    sqlCom.Parameters.Add(new SqlParameter("@lName",(textBox3.Text)));
    sqlCom.Parameters.Add(new SqlParameter("@city",(textBox6.Text)));
    sqlCom.Parameters.Add(new SqlParameter("@pin",(textBox7.Text)));
    sqlCom.Parameters.Add(new SqlParameter("@Phone",(textBox4.Text)));
    sqlCom.Parameters.Add(new SqlParameter("@email",(textBox5.Text)));
    sqlCom.Parameters.Add(new SqlParameter("@orgName",(textBox1.Text)));
    sqlCom.ExecuteNonQuery();
    sqlCom.Dispose();
    MessageBox.Show ("Records has been added");
   }

   catch (Exception ex)
   {
    MessageBox.Show (ex.Source);
    MessageBox.Show (ex.Message);
   }
            
   conClass.closeConnection(); 
  }

2nd
***
private void button1_Click(object sender, System.EventArgs e)
  {
   myconnection conClass = new myconnection();
   conClass.openConnection(); 
   try
   {
   string strsql;
   strsql = "Insert into Authors (au_fname) values ("+ textBox2.Text +")"; 
   SqlDataAdapter sqlDataAdp=new SqlDataAdapter();
   SqlCommand sqlCom = new SqlCommand(strsql, conClass.mysqlconn);
   sqlCom.CommandType = CommandType.Text;
   sqlDataAdp.InsertCommand =sqlCom;
   string @au_fname=textBox2.Text;
   sqlDataAdp.InsertCommand.Parameters.Add(@au_fname,SqlDbType.VarChar,20,"au_fname"); 
     
      
    
    sqlCom.ExecuteNonQuery();


    MessageBox.Show("Done"); 
   }
   catch (Exception ex)
   {
    MessageBox.Show(ex.Source);
    MessageBox.Show(ex.Message);
   }
  }




Regards

Arindam



Yahoo! India Matrimony: Find your partner online.

[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Yahoo! Domains - Claim yours for only $14.70
http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/saFolB/TM
---------------------------------------------------------------------~->

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
     [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 

Reply via email to