Advertisement
Shirai

how to use ExecuteScalar()

Sep 19th, 2014
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.29 KB | None | 0 0
  1. SQLConnection con = new SQLConnection(connection_string);
  2. string query = @"select ten from sinhvien where stt = '5'";
  3. SQLCommand cmd = new SQLCommand(query,con);
  4. string ten = cmd.ExecuteScalar().ToString();
  5. //thế là lấy được tên của người có stt=5 và lưu vào biến ten
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement