using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
///
/// 执行查询首行首列的SQL语句
///
/// 要执行的SQL语句-string
///
public static string ExecuteSql_string(string sql)
{
string str = "";
SqlConnection con = new SqlConnection("DRIVER=SQL Server;SERVER=192.168.1.201;UID=sa;PWD=;DATABASE=ku") ;
try
{
OpenCon(con);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = sql;
str = Convert.ToString(cmd.ExecuteScalar());
}
catch (Exception err)
{
throw new Exception(err.Message);
}
finally
{
CloseCon(con);
}
return str;
}
MsgBOX
MsgBOX.Show(ExecuteSql_string("select sum(lie) from biao"));。
