作业帮 > 综合 > 作业

C# 看不懂,public void frmBooksql(){//打开数据库SqlConnection mySqlCo

来源:学生作业帮 编辑:搜搜考试网作业帮 分类:综合作业 时间:2024/08/10 08:07:38
C# 看不懂,
public void frmBooksql()
{
//打开数据库
SqlConnection mySqlConnection = new SqlConnection(Conn);
mySqlConnection.Open();
string sqlQuery = "SELECT * FROM Book";
SqlCommand mySqlCommand = new SqlCommand(sqlQuery,mySqlConnection);
mySqlCommand.ExecuteNonQuery();
SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter(mySqlCommand);
//填充数据库
DataSet myDs = new DataSet();
mySqlDataAdapter.Fill(myDs);
//关闭数据库
mySqlConnection.Close();
this.dgvBook.DataSource = myDs.Tables[0];
}
private void dgvBook_DataError(object sender,DataGridViewDataErrorEventArgs e)
{
if (e.Exception = null &&
e.Context == DataGridViewDataErrorContexts.Commit)
{
MessageBox.Show("CustomerID value must be unique.");
}
}
private int DoDelete(string paramNo)
{
int returnValue = 0;
BUBook myBUBook = new BUBook();
returnValue = myBUBook.BUDelete(paramNo);
return returnValue;
}
private void Search(string paramNo,string paramName,string paramTyre,string paramState)
{
BUBook myBUBook = new BUBook();
DataTable myDataTable = new DataTable();
myDataTable = myBUBook.BUSearch(paramNo,paramName,paramTyre,paramState);
this.dgvBook.DataSource = myDataTable;
}
private void CheckBike_Load(object sender,EventArgs e)
{
frmBooksql();
BUBook myBUBook = new BUBook();
DataTable myDt = new DataTable();
myDt = myBUBook.BUTyre();
this.cmbTyre.DataSource = myDt;
this.cmbTyre.DisplayMember = "Tyre";
this.cmbTyre.ValueMember = "Tyre";
this.cmbTyre.SelectedValue.ToString();
this.cmbTyre.Text = "";
}
private void btFind_Click(object sender,EventArgs e)
{
string paramNo = this.txtNo.Text.Trim();
string paramName = this.txtName.Text.Trim();
string paramTyre = this.cmbTyre.Text.ToString();
string paramState = this.cmbState.Text.ToString();
this.Search(paramNo,paramName,paramTyre,paramState);
}
private void bt1Home_Click(object sender,EventArgs e)
{
frmintroduction myfrmintroduction = new frmintroduction();
myfrmintroduction.Show();
this.Hide();
this.DialogResult = DialogResult.No;
}
}
C# 看不懂,public void frmBooksql(){//打开数据库SqlConnection mySqlCo
这是数据库操作...不晓得你是哪里不懂的
再问: 哪句都不懂啊。要下载什么东西有解释。初学者。看不懂。蛋疼回复