string sqltxt="Persist Security Info=False;User ID=sa;Initial Catalog=zhongtian;Data Source=ytf;Password=xu;";
SqlConnection sqlcon=new SqlConnection(sqltxt);
try
{
sqlcon.Open();
SqlCommand sqlcm=new SqlCommand("select Max(product_id) from product_class where product_id like '"+e1+"__'",sqlcon);
SqlDataReader dr=sqlcm.ExecuteReader();
if(dr.Read())
{
if(e1.Length==4)
{
textBox1.Text=Int32.Parse(dr.GetValue(0).ToString().Substring(4));
}
//else
//{
                     //  textBox1.Text=dr.GetValue(0).ToString().Substring(6);
//}
//textBox1.Text=dr.GetValue(0).ToString();
sqlcon.Close();
}
}
catch(System.Data.SqlClient.SqlException ex)
{
MessageBox.Show(ex.Message);
}
finally
{
sqlcon.Close();
} }

解决方案 »

  1.   

    sdk里类库的例程多得就是,看看就行了^_^
    system.data.xxx随便看一个就行了
      

  2.   

    string strSql = "select department.* from department";string strConn ="data source=YL5;initial catalog=Address;workstation id=YL5;packet size=4096";SqlConnection conn     = new SqlConnection(strConn);
    SqlCommand cmd_dep     = new SqlCommand(strSql,conn);
    SqlDataAdapter adp_dep = new SqlDataAdapter();adp_dep.SelectCommand  = cmd_dep; 
    DataSet ds             = new DataSet();conn.Open();
    adp_dep.Fill(ds);
    建议你还是先看看帮助:
    Visual Basic 和Visual C# --访问数据--数据演练
      

  3.   

    thanks a lot of