求解
public class StudentService{
#region 从配置文件中读取
//从配置文件中读取数据库连接字符串
private readonly string connString = ConfigurationManager.ConnectionStrings["MySchoolConnectionString"].ToString();
private readonly string dboOwner = ConfigurationManager.ConnectionStrings["DataBaseOwner"].ToString();
#endregion
#region //获取所有学员信息
public DataSet GetAllStudents()
{
DataSet da = new DataSet();
SqlConnection conn = new SqlConnection(dboOwner);
SqlDataAdapter objAdapter = new SqlDataAdapter(dboOwner
+ ".usp_SelectStudentsPartInfo",conn);
objAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;
objAdapter.Fill(da,"studentTable");
conn.Close();
conn.Dispose();
return da;
}
#endregion
求高手 从索引 0 处开始,初始化字符串的格式不符合规范。 --------------------编程问答-------------------- 你的dboOwner应该是数据库的名字吧,connString才是数据库的连接字符串吧
SqlConnection conn = new SqlConnection(connString);
SqlDataAdapter objAdapter = new SqlDataAdapter(dboOwner
+ ".usp_SelectStudentsPartInfo",conn); --------------------编程问答-------------------- .usp_SelectStudentsPartInfo
怎么还会有个.
把你的dboOwner 链接字符串贴出来看 --------------------编程问答-------------------- dboOwner + ".usp_SelectStudentsPartInfo"
这个应该是调用dboOwner下的某个存储过程, --------------------编程问答-------------------- 对啊可是我还是那样啊 --------------------编程问答-------------------- 初始化SqlConnection对象时给与的数据库连接字符串格式不正确
北大青鸟的学生吧
这是ACCP5.0的一贯写法。
App.config文件中的dboOwner字符串应该就是一个dbo吧。
真正的数据库连接字符串为connString
SqlConnection connection = new SqlConnection(connString);
--------------------编程问答-------------------- 呵呵请问你是
补充:.NET技术 , C#