Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0301· OpenAIAi2 WildChat-4.8M (AI2)

what does this mean AdminDGV.DataSource = ds.Tables[0];

  1. User

    what does this mean AdminDGV.DataSource = ds.Tables[0];

  2. Assistant

    This code sets the DataSource property of the AdminDGV object to the first table (identified by the index 0) in the DataSet object ds. This presumably populates the AdminDGV object with data from that table.

  3. User

    private void Clear() { AdminIDTb.Text = ""; AdminUserNameTB.Text = ""; AdminPasswordTb.Text = ""; AdminNameTb.Text = ""; AdminSurnameTb.Text = ""; } replace Admin with Customer

  4. Assistant

    private void Clear() { CustomerIDTb.Text = ""; CustomerUserNameTB.Text = ""; CustomerPasswordTb.Text = ""; CustomerNameTb.Text = ""; CustomerSurnameTb.Text = ""; }

  5. User

    if(AdminIDTb.Text == "" || AdminUserNameTB.Text == "" || AdminPasswordTb.Text == "" || AdminNameTb.Text == "" || AdminSurnameTb.Text == "") { MessageBox.Show("Missing Entries"); } else { try { Con.Open(); SqlCommand cmd = new SqlCommand("insert into AdminTbl (AdminId,AdminUserName,AdminPass,AdminName,AdminSurname,AdminSDate) values(@AID,@AUN,@AP,@AN,@AS,@ASD)", Con); cmd.Parameters.AddWithValue("@AID", AdminIDTb.Text); cmd.Parameters.AddWithValue("@AUN", AdminUserNameTB.Text); cmd.Parameters.AddWithValue("@AP", AdminPasswordTb.Text); cmd.Parameters.AddWithValue("@AN", AdminNameTb.Text); cmd.Parameters.AddWithValue("@AS", AdminSurnameTb.Text); cmd.Parameters.AddWithValue("@ASD", AdminSDateTb.Value.Date); cmd.ExecuteNonQuery(); MessageBox.Show("Admin has been Added to DB"); Con.Close(); DisplayAdmins(); Clear(); } catch(Exception Ex) { MessageBox.Show(Ex.Message); } } } change Admin with Customer

  6. Assistant

    if(CustomerIDTb.Text == "" || CustomerUserNameTB.Text == "" || CustomerPasswordTb.Text == "" || CustomerNameTb.Text == "" || CustomerSurnameTb.Text == "") { MessageBox.Show("Missing Entries"); } else { try { Con.Open(); SqlCommand cmd = new SqlCommand("insert into CustomerTbl (CustomerId,CustomerUserName,CustomerPass,CustomerName,CustomerSurname,CustomerSDate) values(@CID,@CUN,@CP,@CN,@CS,@CSD)", Con); cmd.Parameters.AddWithValue("@CID", CustomerIDTb.Text); cmd.Parameters.AddWithValue("@CUN", CustomerUserNameTB.Text); cmd.Parameters.AddWithValue("@CP", CustomerPasswordTb.Text); cmd.Parameters.AddWithValue("@CN", CustomerNameTb.Text); cmd.Parameters.AddWithValue("@CS", CustomerSurnameTb.Text); cmd.Parameters.AddWithValue("@CSD", CustomerSDateTb.Value.Date); cmd.ExecuteNonQuery(); MessageBox.Show("Customer has been Added to DB"); Con.Close(); DisplayCustomers(); Clear(); } catch(Exception Ex) { MessageBox.Show(Ex.Message); } }

  7. User

    AdminIDTb.Text = AdminDGV.SelectedRows[0].Cells[0].Value.ToString(); AdminUserNameTB.Text = AdminDGV.SelectedRows[0].Cells[1].Value.ToString(); AdminPasswordTb.Text = AdminDGV.SelectedRows[0].Cells[2].Value.ToString(); AdminNameTb.Text = AdminDGV.SelectedRows[0].Cells[3].Value.ToString(); AdminSurnameTb.Text = AdminDGV.SelectedRows[0].Cells[4].Value.ToString(); if(AdminIDTb.Text == "") { key = 0; } else { key = Convert.ToInt32(AdminDGV.SelectedRows[0].Cells[0].Value.ToString()); } replace Admin with Customer

  8. Assistant

    CustomerIDTb.Text = CustomerDGV.SelectedRows[0].Cells[0].Value.ToString(); CustomerUserNameTB.Text = CustomerDGV.SelectedRows[0].Cells[1].Value.ToString(); CustomerPasswordTb.Text = CustomerDGV.SelectedRows[0].Cells[2].Value.ToString(); CustomerNameTb.Text = CustomerDGV.SelectedRows[0].Cells[3].Value.ToString(); CustomerSurnameTb.Text = CustomerDGV.SelectedRows[0].Cells[4].Value.ToString(); if(CustomerIDTb.Text == "") { key = 0; } else { key = Convert.ToInt32(CustomerDGV.SelectedRows[0].Cells[0].Value.ToString()); }

  9. User

    SqlCommand cmd = new SqlCommand("insert into CustomerTbl (CustomerId,CustomerUserName,CustomerPass,CustomerName,CustomerSurname,CustomerSDate) values(@CID,@CUN,@CP,@CN,@CS,@CSD)", Con); replace Customer with Cust

  10. Assistant

    SqlCommand cmd = new SqlCommand("insert into CustTbl (CustId,CustUserName,CustPass,CustName,CustSurname,CustSDate) values(@CID,@CUN,@CP,@CN,@CS,@CSD)", Con);

  11. User

    SqlCommand cmd = new SqlCommand("Update AdminTbl set AdminId=@AID,AdminUserName=@AUN,AdminPass=@AP,AdminName=@AN,AdminSurname=@AS,AdminSDate=@ASD where AdminID=@AID", Con); Replace Admin with Cust

  12. Assistant

    SqlCommand cmd = new SqlCommand("Update CustTbl set CustId=@CID,CustUserName=@CUN,CustPass=@CP,CustName=@CN,CustSurname=@CS,CustSDate=@CSD where CustID=@CID", Con);