จะส่งค่า c จากฟังก์ชั่นด้านล่าง ไป อีกฟังก์ชั่นอย่างไงครับ
//------------------------------------------------------------------
private void count()
{
MySqlCommand comm = new MySqlCommand("SELECT count( book_count ) FROM books_dt where book_id = '" + txtbookid.Text + "'", conn);
conn.Open();
MySqlDataReader dr = comm.ExecuteReader();
if (dr.Read())
{
string c;
c = dr.GetValue(0).ToString(); // c ในแถวนี้
}
conn.Close();
}
//-------------------------------------------------------------------
มายังฟังก์ชั่นนี้
private void updateAfterDel()
{
string strconn;
strconn = "update tb_books set book_total = '" + ccตัวนี้ + "' where book_id = '" + txtbookid.Text + "' ";
conn = new MySqlConnection("Server=localhost;Database=booksrent;Uid=root;Pwd=root;");
cmd = new MySqlCommand(strconn, conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
ส่งค่าอย่างไร c#
//------------------------------------------------------------------
private void count()
{
MySqlCommand comm = new MySqlCommand("SELECT count( book_count ) FROM books_dt where book_id = '" + txtbookid.Text + "'", conn);
conn.Open();
MySqlDataReader dr = comm.ExecuteReader();
if (dr.Read())
{
string c;
c = dr.GetValue(0).ToString(); // c ในแถวนี้
}
conn.Close();
}
//-------------------------------------------------------------------
มายังฟังก์ชั่นนี้
private void updateAfterDel()
{
string strconn;
strconn = "update tb_books set book_total = '" + ccตัวนี้ + "' where book_id = '" + txtbookid.Text + "' ";
conn = new MySqlConnection("Server=localhost;Database=booksrent;Uid=root;Pwd=root;");
cmd = new MySqlCommand(strconn, conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}