Click here to Skip to main content
15,904,877 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
`hi this azadkumarreddy
i took 2 lables,2 textboxs for username and password,1 button, so when i click button then store the username and password into table in sqlserver, and also navigate to another page.

could u please help me with code
Posted
Comments
[no name] 28-Nov-11 20:27pm    
you should have googled this one!

C#
public static bool Insert_File(string FileNo, string CUSTOMER_NAME, string ProjectName, string STATUS,string date,string ins)
    {
        try
        {
            string stinsert = "Insert into File (FileNo,CUSTOMER_NAME,ProjectName,STATUS,IDate,InsertedBy) values (@FileNo,@CUSTOMER_NAME,@ProjectName,@STATUS,@date,@ins)";
            //string stinsert1 = "Insert into FileCord (FileNo,CUSTOMER_NAME,ProjectName,STATUS,IDate) values (@FileNo,@CUSTOMER_NAME,@ProjectName,@STATUS,@date)";

            OleDbCommand cmdinsert = new OleDbCommand(stinsert, GetConnection());

            cmdinsert.Parameters.AddWithValue("FileNo", FileNo);
            cmdinsert.Parameters.AddWithValue("CUSTOMER_NAME", CUSTOMER_NAME);
            cmdinsert.Parameters.AddWithValue("ProjectName", ProjectName);
            cmdinsert.Parameters.AddWithValue("STATUS", STATUS);
            cmdinsert.Parameters.AddWithValue("date",date);
            cmdinsert.Parameters.AddWithValue("ins",ins);
            cmdinsert.ExecuteNonQuery();
            cmdinsert.Connection.Close();
            return true;

        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
            return false;
        }
    }



For Update

C#
public static bool Update_Received(string FileNo, string ReqControlNo, string ReceiveDate, string Remarks, string received)
    {
        try
        {
            string s1 = "Update Issue set ReceivedDate='" + ReceiveDate + "',ReceivedRemarks= '" + Remarks + "',ReceiveTime='" + received + "' where FileNo='" + FileNo + "' AND ReqControlNo='" + ReqControlNo + "'";
            OleDbCommand cmd1 = new OleDbCommand(s1, GetConnection());
            cmd1.ExecuteNonQuery();
            cmd1.Connection.Close();
            string stts = "Available";
            string st3 = "Update File set STATUS='" + stts + "' where FileNo='" + FileNo + "' ";
            OleDbCommand cmd11 = new OleDbCommand(st3, GetConnection());
            cmd11.ExecuteNonQuery();
            cmd11.Connection.Close();
 
            return true;
 
        }
        catch (Exception ex)
        {
 
            System.Windows.Forms.MessageBox.Show(ex.ToString());
            return false;
        }
 
Share this answer
 
v2
Comments
walterhevedeich 27-Sep-11 21:04pm    
Why not use parameters too on the update part?
quite simply no - do some research, stop posting homework and use google!
 
Share this answer
 
 
Share this answer
 
v2
Learn to use Google before posting your question here.

Check THIS[^]



hope it helps :)
 
Share this answer
 
for sample application downlaod this project

http://www.c-sharpcorner.com/Blogs/3649/[^]
 
Share this answer
 

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



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