sno name mobile referalid area
1 shashi 8985500166 15432 hyd
2 vamshi 9014498762 12345 sec
i wnt output like this ......
when i entered mobile no in textbox display name in secondbox and display referal id in third box .................
plz write the code..................
Satyapriya NayakPosted Jun 14, 2013, 9:26 AM
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace Textbox_related_data
{
public partial class Form1 : Form
{
string ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["dsn"];
OleDbCommand com;
string str;
public Form1()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
textBox2.Text = "";
textBox3.Text = "";
OleDbConnection con = new OleDbConnection(ConnectionString);
con.Open();
str = "select * from emp where mobile='" + textBox1.Text + "'";
com = new OleDbCommand(str, con);
OleDbDataReader reader = com.ExecuteReader();
while (reader.Read())
{
textBox2.Text = reader["name"].ToString();
textBox3.Text = reader["referalid"].ToString();
}
con.Close();
reader.Close();
}
}
}
Jignesh TrivediPosted Jun 14, 2013, 7:04 AM
i think this is same as
http://www.c-sharpcorner.com/Forums/Thread/213479/read-the-values-fraom-table.aspx
Pankaj PandeyPosted Jun 14, 2013, 3:51 AM
sqlconnection conn=new sqlconnection("your connection string");
sqlcommand cmd=new sqlcommand("select top(1) name,referalid from table where mobile='"+textbox1.Text+"'", conn);
sqldataadapter da=new sqldataadapter(cmd);
datatable dt=new datatable();
da.Fill(dt);
textbox2.Text=dt.rows[0]["name"].tostring();
textbox3.Text=dt.rows[0]["referalid"].tostring();
mark as answered if helpfull
Riyaz AkhtarPosted Jun 14, 2013, 3:50 AM
create an event OnTextChanged in your mobile textbox and make AutoPostBack="True" in this textbox. Write code to display name and referal Id in OnTextChanged event
Thanks
RA