|
2008-4-12, 1:12 AM
|
忘月轩
 等级: 士兵
注册: 2008年4月12日
积分: 2
精华: 0
发贴: 1
|
|
|
|
小弟初学,对C#也不是很懂,我学的是VB,请哪位高手帮忙看下,搞了好久也没搞明白是什么原因。先谢过了~ 编译器错误信息: CS0246: 找不到类型或命名空间名称“datatable”(是否缺少 using 指令或程序集引用?)
源错误:
|
行 39: } 行 40: } 行 41: public static datatable selectallperson() 行 42: { 行 43: OleDbConnection con = personopreate.createcon(); | 程序如下: 行 1: using System; 行 2: using System.Data.OleDb ; 行 3: using System.Configuration; 行 4: using System.Web; 行 5: using System.Web.Security; 行 6: using System.Web.UI; 行 7: using System.Web.UI.WebControls; 行 8: using System.Web.UI.WebControls.WebParts; 行 9: using System.Web.UI.HtmlControls; 行 10: /// <summary> 行 11: /// personopreate 的摘要说明 行 12: /// </summary> 行 13: public class personopreate 行 14: { 行 15: public personopreate() 行 16: { 行 17: 行 18: // 行 19: // TODO: 在此处添加构造函数逻辑 行 20: // 行 21: } 行 22: public static OleDbConnection createcon() 行 23: { 行 24: return new OleDbConnection("provider=microsoft.jet.oledb.4.0;datasourse=adonet.mdb;"); 行 25: } 行 26: public static bool findperson(string pID) 行 27: { 行 28: OleDbConnection con = personopreate.createcon; 行 29: con.Open; 行 30: OleDbCommand cmd = new OleDbCommand("select count(*) from person where pID='+personId+'", con); 行 31: int count = Convert.ToInt32(cmd.ExecuteScalar); 行 32: if (count > 0) 行 33: { 行 34: return true; 行 35: } 行 36: else 行 37: { 行 38: return false; 行 39: } 行 40: } 行 41: public static datatable selectallperson() 行 42: { 行 43: OleDbConnection con = personopreate.createcon(); 行 44: OleDbDataAdapter sda = new OleDbDataAdapter(); 行 45: sda.SelectCommand = new OleDbCommand("select * from person", con); 行 46: dataset ds = new dataset(); 行 47: sda.Fill(ds, "person"); 行 48: return ds.tables["person"]; 行 49: } 行 50: public static bool insertperson(person p) 行 51: { 行 52: try 行 53: { 行 54: OleDbConnection con = personopreate.createcon; 行 55: con.Open; 行 56: OleDbcommand cmd = new OleDbCommand("insert into person values(@personId,@personName,@personSex)", con); 行 57: OleDbParameter para = new OleDbParameter("@personId", OleDbType.Char, 10); 行 58: para.Value = p.pID; 行 59: cmd.parameters.add(para); 行 60: para = new OleDbParameter("@personName", OleDbType.Char, 20); 行 61: para.Value = p.pName; 行 62: cmd.parameters.add(para); 行 63: para = new OleDbParameter("@personSex", OleDbType.Char, 2); 行 64: cmd.parameters.add(para); 行 65: cmd.executenonquery(); 行 66: return true; 行 67: } 行 68: catch (Exception e) 行 69: { 行 70: return false; 行 71: } 行 72: } 行 73: }
|
|
|
IP 地址: 已登录
来自: 已登录
|
|
|
|
|
|
|
|