hey I'm already done for the searching method and all i want to do is to put the data into the textbox.
For example I need pull data from DB using ID and set other info in required text box, ID is provided by user in a Text Box.
thanks for helping me.. :)) GOD BLESS!
my code.....
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace WindowsFormsApplication17.Forms
{
public partial class Form7 : Form
{
public Form7()
{
InitializeComponent();
}
private void btnAdd_Click(object sender, EventArgs e)
{
string input = txtStudID.Text.Trim();
string conn = "server=localhost;user=root;password=1;database=record;";
MySqlConnection myconn = new MySqlConnection(conn);
string sql = "SELECT `StudentID` FROM `Information` WHERE `StudentID` = '" + input + "';";
MySqlDataAdapter da = new MySqlDataAdapter(sql, myconn);
MySqlDataReader reader;
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count == 0)
{
MessageBox.Show(input + " does not exist.", "Not Exists");
txtStudID.Focus();
txtStudID.Text = "";
}
else
{
//this for textboxes that will display the data from column..
txtStudName.Text = dt.Columns[0] + "";
txtAdd.Text = dt.Columns + "address";
txtContact.Text = dt.Columns + "Contact";
}
}
private void btnClose_Click(object sender, EventArgs e)
{
Form1 form1 = new Form1();
form1.Show();
this.Hide();
}
}
}