1. According to the need to query the MySQL statement, return three required parameters, not a data set
2. Write functions such as the following:
public static void Getparas (string condition 1, out string return value 1, out string return value 2, out string return value 3)
{
The return value is 1= string. Empty;
The return value is 2= string. Empty;
The return value is 3= string. Empty;
String strSQL = String. Format ("SELECT * from table where field 1= ' {0} ' limit 1", condition 1);
Run the SQL statement
DataTable dt = ds. Tables[0];
if (dt! = null && dt. Rows.Count = = 1)
{
Object obj = dt. rows[0][return value 1 "];
if (obj! = null &&!) ( obj is DBNull))
{
The return value 1= convert.tostring (obj). Replace ("", "");
}
obj = dt. rows[0]["return value 2"];
if (obj! = null &&!) ( obj is DBNull))
{
The return value 2= convert.tostring (obj);
}
obj = dt. rows[0]["return value 3"];
if (obj! = null &&!) ( obj is DBNull))
{
The return value 3= convert.tostring (obj);
}
}
}
3. With the SQL run above, the corresponding three return values are queried.
4. Call functions such as the following
String returns a value of 1= string. Empty;
String returns a value of 2= string. Empty;
String returns a value of 3= string. Empty;
Getparas (query condition 1, out return value 1, out return value 2, out return value 3);
C # Query SQL returns multiple parameters