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 处开始,初始化字符串的格式不符合规范。

解决方案 »

  1.   

    你的dboOwner应该是数据库的名字吧,connString才是数据库的连接字符串吧SqlConnection conn = new SqlConnection(connString);
    SqlDataAdapter objAdapter = new SqlDataAdapter(dboOwner
      + ".usp_SelectStudentsPartInfo",conn);
      

  2.   

    .usp_SelectStudentsPartInfo怎么还会有个.把你的dboOwner 链接字符串贴出来看
      

  3.   

    dboOwner  + ".usp_SelectStudentsPartInfo"这个应该是调用dboOwner下的某个存储过程,
      

  4.   

    初始化SqlConnection对象时给与的数据库连接字符串格式不正确北大青鸟的学生吧这是ACCP5.0的一贯写法。App.config文件中的dboOwner字符串应该就是一个dbo吧。真正的数据库连接字符串为connString
    SqlConnection connection = new SqlConnection(connString);