用类的对象来调用:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
//对数据库的操作封装在类中
using System;
using System.Configuration;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace jobstar_lkk.module
{
public class Country
{
protected SqlConnection conn;
protected SqlCommand comm=new SqlCommand();
protected dbConn CoOp=new dbConn();
protected SqlDataAdapter coda;
protected DataSet cods=new DataSet();
protected string sqlword;
public DataSet get_list(string seekword)
{
conn = CoOp.getConnection();
comm =conn.CreateCommand();
if(seekword.Length!=0)
seekword=" and "+seekword;
sqlword = "select * from tb_country where id>0" + seekword;
coda = new SqlDataAdapter(sqlword, conn);
coda.Fill(cods,"Country");
conn.Close();
return cods;
}
public void fill_list(string seekword,DataSet fillds)
{
conn = CoOp.getConnection();
comm.Connection = conn;
if(seekword.Length!=0)
seekword=" and "+seekword;
sqlword = "select * from tb_country where id>0 " + seekword;
coda = new SqlDataAdapter(sqlword, conn);
coda.Fill(fillds,"Country");
conn.Close();
}
public class CountryDetail //国家表详细内容
{
private int id;
protected SqlConnection conn;
protected SqlCommand comm=new SqlCommand();
protected dbConn CoOp=new dbConn();
protected SqlDataAdapter coda;
protected DataSet cods=new DataSet();
protected string sqlword,name;
public string get_name
{
get
{
return name;
}
set
{
name=value;
}
}
public int get_id
{
get
{
return id;
}
set
{
id=value;
}
}
public void get_ds()
{
conn = CoOp.getConnection();
comm.Connection = conn;
sqlword = "select * from tb_country where id=" +id;
if(id>0)
{
coda = new SqlDataAdapter(sqlword, conn);
coda.Fill(cods, "Country");
DataRow newRow= cods.Tables["Country"].Rows[0];
name=newRow["name"].ToString();
}
}