帮帮我!C#学的不好 就象你写数据库连接的类一样,然后每个页面都可以用是吗?好象就在ADDCODE里面添加一个类/CS,而且好象要记得都用public修饰,有强人继续解答,我也刚学,呵呵 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你直接添加一个类文件,具体类的语法不说了,如果你添加的是一个类库项目,在生成后,在WEB项目中先添加引用,然后在WEB页面就可以用了,由类库文件的命名空间引出,如果是直接添加的类文件,在WEB页面直接就可以用,也是由命名空间引出,具体的还是查一下资料比较好 再项目中添加一个xxx.cs文件(最好放在App_Code目录中),文件内容类似:using System;using System.Data;using System.Data.OleDb;using System.Text.RegularExpressions;/// <summary>/// Conn 的摘要说明/// </summary>public class Conn{ public static OleDbConnection conn = new OleDbConnection(); public static OleDbConnection connAccess(String DbPath_v) { if (conn.State == ConnectionState.Connecting) { return conn; } else { conn = new OleDbConnection(GetConnString(DbPath_v)); return conn; } } private static string GetConnString(String DbPath_v) { return System.Configuration.ConfigurationSettings.AppSettings["ConnStr"] + System.Web.HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationSettings.AppSettings[DbPath_v]); } public static string replaceQ(String str1) { return str1.Replace('\'', '\"'); } public static object chkNull(object obj1) { if (obj1 is System.DBNull) { switch (obj1.GetType().ToString()) { case "System.int": case "System.Int16": case "System.Int32": case "System.Int64": case "System.Decimal": case "System.Single": { return 0; break; } case "System.String": { return ""; break; } default: { return ""; break; } } } else { return obj1; } }} 将字节数组格式保存的位图转换成域位数组 C# 怎么匹配图片? 怎样将选定文件夹中的所有文件读入数据库? 二進制數據轉換成文檔 请教高手,来解决下这个问题!!! 未能将图像添加到 ImageList 'HTTP/1.1 500 Internal Server Error'. 如何以百分比形式显示小数? 在WinForm绘图过程中出现了一个奇怪的问题,求解答! 两个问题!!!先谢 c#是不是不可以直接操作dbf文件的? listview列标头背景色能否改变
using System;
using System.Data;
using System.Data.OleDb;
using System.Text.RegularExpressions;/// <summary>
/// Conn 的摘要说明
/// </summary>
public class Conn
{
public static OleDbConnection conn = new OleDbConnection(); public static OleDbConnection connAccess(String DbPath_v)
{
if (conn.State == ConnectionState.Connecting)
{
return conn;
}
else
{
conn = new OleDbConnection(GetConnString(DbPath_v));
return conn;
}
}
private static string GetConnString(String DbPath_v)
{
return System.Configuration.ConfigurationSettings.AppSettings["ConnStr"] +
System.Web.HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationSettings.AppSettings[DbPath_v]);
} public static string replaceQ(String str1)
{
return str1.Replace('\'', '\"');
} public static object chkNull(object obj1)
{
if (obj1 is System.DBNull)
{
switch (obj1.GetType().ToString())
{
case "System.int":
case "System.Int16":
case "System.Int32":
case "System.Int64":
case "System.Decimal":
case "System.Single":
{
return 0;
break;
}
case "System.String":
{
return "";
break;
}
default:
{
return "";
break;
}
}
}
else
{
return obj1;
}
}
}