我是个新手,到目前为止,我只能用源代码写,用SqlConnection等控件好象很麻烦,谁能指导一下

解决方案 »

  1.   

    啊???????
    再说一遍:
    DataGrid绑定数据库不写代码能不能实现??????????有无其它方法?工具箱->数据栏 不是有一些sqlconnection,sqlcommand之类的控件吗?用那个应该可以绑数据的吧?????怎么绑定啊?
      

  2.   

    >>>DataGrid绑定数据库不写代码能不能实现??????????you could do it by datagrid control, but codes will more free and simple to realize you purpose
    >>>>工具箱->数据栏 不是有一些sqlconnection,sqlcommand之类的控件吗?用那个应该可以绑数据的吧?????怎么绑定啊?
    sqlconnection is use to connect with database,
    sqlcommand is use to deal with your sql command or execute your sql command.
      

  3.   

    不麻烦,先拖个DataAdapter控件,系统会自动创建一个Connection对象
    然后右键点DataAdapter控件,选择生成DataSet来生成一个DataSet
    设置好你的每个控件要绑定的数据字段
    在page_load中用DataAdapter.Fill(DataSet)就可以了
      

  4.   

    to tangjun(俊)
    用你的方法,编缉的时候可以在datagrid中看到数据,但编译后,就什么都没了
    我在page_load中写了DataAdapter.Fill(DataSet),也没反映,,,
    怎么回事啊?
      

  5.   

    using System.Data;
    using System.Data.SqlClient;//
    string strConn = "Connstring";
    string strSQLCmd = "select gradevalue,descript from grade_detail where yearset=2003 and monthset=1 and ntaccount='chenha' and items='WD'";SqlConnection objConn = new SqlConnection();
    objConn.ConnectionString = strConn;
    objConn.Open();SqlCommand objSQLCmd = new SqlCommand(strSQLCmd, objConn);
    SqlDataReader objDataReader = objSQLCmd.ExecuteReader();
    DataGrid1.DataSource = objDataReader;
    DataGrid1.DataBind();objConn.Close();