第1个回答 2010-06-22
string str="server=.;uid="数据库登录名";database="数据库名";pwd="数据库密码";
SqlConnection con = new SqlConnection(str);//XXX为你的连接字符串
SqlCommand cmd = new SqlCommand();//实体化SqlCommand
cmd.Connection=con;//为cmd的Connetion属性赋值
cmd.CommandText="SELECT para FROM sys WHERE id='admin'"//查询语句@id为参数
con.Open();//打开连接
string res=cmd.ExcuteScalar().ToString();//获取你需要的结果
con.Close();//关闭连接
第2个回答 2010-06-22
connection conn=new connection();
string str="server=.;uid="数据库登录名";database="数据库名";pwd="数据库密码";
conn.open();
command cmd=new command();
cmd(str,conn);
string str1="select para from sys where id='admin'";
string str2=cmd.excuteScalre();
conn.close();
str2就是para的值;