Hi,
I have a problem.iam working on windows application in C#.I have 10 textboxs in windows form.When iam entering ITEMCODE in first textbox then immediatly ITEM data will be displyed in remaining textboxs.this is my scenario.how to get data?plz help me.
himanshu
Loading
Kirtan PatelPosted Sep 1, 2009, 8:18 AM
Below Code is for what you exactly want to
as you type in textBox it will search records From database and Fill the Text Boxes
I have Coded Below sample for that
if you don't understand the code i have also included sample Project Files. Download them and Take a Look at them Link is at Bottom of The post
using System.Data.SqlClient;
namespace WindowsFormsApplication48
{
public partial class Form1 : Form
{
DataView dv;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// Connect to Database and Point DV to dataset Once then you can filter any time
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True");
con.Open();
SqlCommand comm = new SqlCommand("select * from Users", con);
SqlDataAdapter da = new SqlDataAdapter(comm);
DataSet ds = new DataSet();
da.Fill(ds, "vtable");
dv = ds.Tables[0].DefaultView;
}
private void txtUsername_TextChanged(object sender, EventArgs e)
{
// Your Main Searching Code
try
{
if (txtUsername.Text != "")
{
//filter the result very Fast Without Connecting DataBase
dv.RowFilter = "username like '" + txtUsername.Text + "'";
// Set Password textBox Text To Filtered Row Column 2 Text
txtPassword.Text = dv[0][1].ToString();
}
else
{
txtPassword.Text = "";
}
}
catch
{
}
}
}
}
Download Project Files
roy himanshuPosted Sep 1, 2009, 9:32 AM
its working.thank u
himanshu
roy himanshuPosted Sep 1, 2009, 7:36 AM
thanx for response,still now iam getting error.the error message is
ExecuteReader require an open and available Connection.The Connections current state is closed
this is error.plz rectify my problem.plz help me
himanshu
Niradhip ChakrabortyPosted Sep 1, 2009, 6:08 AM