Help In Using Datagridview In Csharp

Discussion in 'General Computer Support' started by jedlarosa, Dec 2, 2009.

  1. jedlarosa

    jedlarosa

    Joined:
    Dec 1, 2009
    Messages:
    1
    Hi guys! Im a Filipino and this is my first time here in this site, hopefully, in this site! Will end my problems using the datagridview in csharp...

    well.. here it goes!:veryprou:

    here is the codes in my sqldatareader:

    CON.Open();
    SqlCommand CMD4 = new SqlCommand();
    CMD4.Connection = CON;
    CMD4.CommandType = CommandType.StoredProcedure;
    CMD4.CommandText = "Tardiness_Select";
    CMD4.Parameters.Add("Emp_ID", SqlDbType.NChar).Value= searchbox.Text;

    SqlDataReader CyberSelector = CMD4.ExecuteReader();
    if (CyberSelector.HasRows)
    {
    fnFieldTardiness(false, false, true);
    CyberSelector.Read();
    txtempid2.Text = CyberSelector["Emp_ID"].ToString();
    txtfname3.Text = CyberSelector["Fullname"].ToString();


    CON.Close();

    }

    else
    {
    MessageBox.Show("Record Not Found!");
    }

    CON.Close();

    AND THE CODES THAT I USED FOR MY DATAGRIDVIEW

    string connectionString;
    SqlConnection connection;
    DataSet ds = new DataSet();
    string Sql;
    connectionString = @"Data Source=CYBERNETIC\BESHYEXPRESS;Initial Catalog=LCIS2;User ID=CyberAccount;Password=12345";
    connection = new SqlConnection(connectionString);
    Sql = "select * from TblTardiness where Emp_ID = @Emp_ID";
    try
    {
    connection.Open();
    adapter = new SqlDataAdapter(Sql, connection);
    adapter.Fill(ds);
    connection.Close();
    dataGridView1.DataSource = ds.Tables[0];
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.ToString());
    }





    My question is....

    how will I use OR get the value of Emp_ID from searchbox.Text that I inputted like "3471414" for the DATAGRIDVIEW FOR IT TO BE SEARCH THE RECORDS under and only covered by that Emp_ID ONLY????

    because the error is: Must declare the scalar variable "@Emp_ID".

    please guys need help as soon as possible... the deadline of our project is in december 16! please guys... please help me:-(
     
    Last edited: Dec 2, 2009
    jedlarosa, Dec 2, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. auratius@gmail.com

    CSharp windows Preparation - Free Course

    auratius@gmail.com, Mar 9, 2007, in forum: MCAD
    Replies:
    0
    Views:
    421
    auratius@gmail.com
    Mar 9, 2007
  2. Razwan

    Convert DataGridView to XML

    Razwan, Aug 27, 2009, in forum: Software
    Replies:
    0
    Views:
    1,360
    Razwan
    Aug 27, 2009
  3. mpv55
    Replies:
    0
    Views:
    1,650
    mpv55
    Feb 13, 2010
  4. Ruchi22

    Datagridview + checkbox + button

    Ruchi22, Sep 28, 2011, in forum: Software
    Replies:
    0
    Views:
    1,118
    Ruchi22
    Sep 28, 2011
  5. Ruchi22

    Looping in Datagridview

    Ruchi22, Oct 15, 2011, in forum: Software
    Replies:
    0
    Views:
    999
    Ruchi22
    Oct 15, 2011
Loading...

Share This Page