Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > General Computer Support > Help In Using Datagridview In Csharp

Reply
Thread Tools

Help In Using Datagridview In Csharp

 
 
jedlarosa jedlarosa is offline
Junior Member
Join Date: Dec 2009
Posts: 1
 
      12-02-2009
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!

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 by jedlarosa; 12-02-2009 at 12:33 AM..
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help:Filter datagridView with mulitple ComboBox SAM ASP .Net 0 04-18-2008 04:50 PM
csharp syntax help =?Utf-8?B?cm9kY2hhcg==?= ASP .Net 6 02-09-2007 01:48 PM
tool to make a class diagram from csharp Piero Massari ASP .Net 1 06-17-2004 09:14 PM
ASP.NET not processing CSharp code CSDunn ASP .Net 5 01-14-2004 07:59 PM
Re: Project templatefor for ASP.NET in VB (Not CSharp), Natty Gur ASP .Net 0 07-27-2003 06:47 AM



Advertisments