偶也不知道算不算,反正我自己随时写的用,很粗浅的,适合跟我一样的新手收藏,指不定就用得上呢!
一组是我这两天写留言本的
另组是以前vs2003写投票用的
高手看见的话,麻烦把好的解决方案说下,谢谢哦!!新手的话,共同学习了!!
--------下面是我最近写个留言本用的------------
public static oledbconnection con()
{//数据库连接类
oledbconnection con = new oledbconnection(configurationmanager.connectionstrings["book"].connectionstring);
return con;
}
public static bool insert(string que)
{ //根据传进来的sql语句执行插入操作
oledbconnection con = odb.con();
con.open();
oledbcommand cmd = new oledbcommand(que,con);
int count = convert.toint32(cmd.executenonquery());
if (count > 0)
return true;
else
return false;
con.close();
}
public static datatable ds(string que)
{//返回一个装载了sql制定留言的数据表,
oledbconnection con = odb.con();
oledbdataadapter oda = new oledbdataadapter();
oda.selectcommand=new oledbcommand(que,con);
dataset ds = new dataset();
oda.fill(ds,"thc");
return ds.tables["thc"];
con.close();
}
public static bool img(string que)
{//根据传来的条件查询该项是否有内容,有就返回true
oledbconnection con = odb.con();
con.open();
oledbcommand cmd = new oledbcommand(que,con);
if (cmd.executescalar().tostring() != "")
return true;
else
return false;
con.close();
}
public static string scr(string que)
{//同样是根据传来的sql语句返回一个字段的值,我不太喜欢把sql语句做在内中,感觉不灵活
oledbconnection con = odb.con();
con.open();
oledbcommand cmd = new oledbcommand(que,con);
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器