这是类里面的
using System;
using System.Data.SqlClient;
namespace exam
{
public class DB
{
static public SqlConnection CreateFac()
{
return CreateFac("pubs");
}
static public SqlConnection CreateFac(string strDB)
{
string strcon="uid =sa;database="+strDB;
SqlConnection con = new SqlConnection(strcon);
return con;
}
}
}
这是我直接连接的
string strConn = "Data Source=localhost;initial catalog=pubs;integrated security=true;";
[此贴子已经被作者于2007-2-11 15:49:06编辑过]