public UserControl3()
{
InitializeComponent();
SQLiteConnection sqlcon = new SQLiteConnection("Data Source = carRentalDB.db;Version = 3; New = False; Compress = True;");
SQLiteCommand sqlcmd = new SQLiteCommand("SELECT * FROM Client", sqlcon);
sqlcon.Open();
SQLiteDataAdapter sda = new SQLiteDataAdapter(sqlcmd);
DataSet ds = new DataSet();
sda.Fill(ds);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
cbClient.Items.Add(ds.Tables[0].Rows[i][2] + " , " + ds.Tables[0].Rows[i][1]);
}
SQLiteConnection con = new SQLiteConnection("Data Source = carRentalDB.db;Version = 3; New = False; Compress = True;");
SQLiteCommand cmd = new SQLiteCommand("SELECT * FROM Car", con);
con.Open();
SQLiteDataAdapter da = new SQLiteDataAdapter(cmd);
DataSet data = new DataSet();
da.Fill(data);
for (int i = 0; i < data.Tables[0].Rows.Count; i++)
{
cbCar.Items.Add(data.Tables[0].Rows[i][3] + " - " + data.Tables[0].Rows[i][2] + " - " + data.Tables[0].Rows[i][1]);
}
}
this is from my combo box
private void LoadData()
{
setConnection();
sql_con.Open();
sql_cmd = sql_con.CreateCommand();
string CommandText = "SELECT Rents.rental_id,Client.lName,Client.fName,Car.car_brand,Car.car_model,Car.plate_number,Rents.rental_date,Rents.return_date,Car.rate,Rents.rental_status From Rents INNER JOIN Client ON Rents.ID = Client.ID INNER JOIN Car ON Rents.car_id = Car.car_id";
DB = new SQLiteDataAdapter(CommandText, sql_con);
DS.Reset();
DB.Fill(DS);
DT = DS.Tables[0];
dgvRent.DataSource = DT;
sql_con.Close();
}
load data from database
private void cbClient_Click(object sender, EventArgs e)
{
}
what is my sql statement here to save and show the data in data grid view to different user control data grid view
What I have tried:
i tried insert into but it did show in my data grid view