易截截图软件、单文件、免安装、纯绿色、仅160KB

关于ACCESS下OleDbParameter的使用

今天,还是在做那个项目,依然使用往常的sqlhelper用法,往常的数据库操作类,但是偏偏调试不成功,而且最重要的是,它不报错
中午吃饭回来,本来想打算睡个午觉的,但是项目太紧迫了,于是又跟车车研究了一中午,最后,发现如果不用@参数传递的话,是正常运行的,于是百度了一下,那些人说要用“?”当占位符
我想想觉得不正确,于是做了一个实验,发现那是假话
晚上回来,国龙帮我解决了这个问题了
原来,sqlhelper对参数赋值的时候,是循环来赋值的,也就是说,string sql="";中的参数位置,与
 OleDbParameter[] paras ={ new OleDbParameter("@introduction",company.Introduction),
                                  new OleDbParameter("@company_ID",company.Company_ID)
                                    };中参数的位置要对应,
其实想想也是
参数赋值错误,最多就执行不正确,不会出现报错的
先公布代码吧!!!
public bool Update_Company(Company company)
{
bool flag = false;
string sql = "update tb_company set introduction=@introduction where company_ID=@company_ID";
OleDbParameter[] paras ={ new OleDbParameter("@introduction",company.Introduction),
new OleDbParameter("@company_ID",company.Company_ID)
};
int res = SqlHelper.doExecuteNonQuery(sql, paras);
if (res > 0)
{
flag = true;
}
return flag;
}
public int doExecuteNonQuery(string sql,OleDbParameter[] prams)
{
cmd = new OleDbCommand(sql, GetConn());
// cmd.Parameters.Add("introduction", OleDbType.VarChar, 1000, "introduction").Value = new Company().Introduction;
//cmd.Parameters.Add("company_ID", OleDbTyp


相关文档:

ACCESS和MSSQL 如何随机读取数据库记录

查询语句只要这样写,就可以随机取出记录了
SQL="Select top 6 * from Dv_bbs1 where isbest = 1 and layer = 1 order by newID() desc"
在ACCESS里
SELECT top 15 id from tablename order by rnd(id)
SQL Server:
Select TOP N * from TABLE Order By NewID()
Access:
Select TOP N * from TABLE Order By Rnd(ID ......

VC修改Access密码

void ModifyDBCode()
{
 CString strPath;
 ::GetModuleFileName(GetModuleHandle(NULL),strPath.GetBuffer(256),256);
 strPath.ReleaseBuffer();
 int flag=strPath.ReverseFind('\\');
 int size=strPath.GetLength();
 strPath.Delete(flag,size-flag);
 strPath= strPath+ ......

java access sql

JDBC连接MySQL
加载及注册JDBC驱动程序
Class.forName("com.mysql.jdbc.Driver");
Class.forName("com.mysql.jdbc.Driver").newInstance();
JDBC URL 定义驱动程序与数据源之间的连接
标准语法:
<protocol(主要通讯协议)>:<subprotocol(次要通讯协议,即驱动程序名称)>:<da ......

Sql Server 和 Access 操作数据库结构Sql语句

新建表:
create table [表名]
(
[自动编号字段] int IDENTITY (1,1) PRIMARY KEY ,
[字段1] nVarChar(50) default '默认值' null ,
[字段2] ntext null ,
[字段3] datetime,
[字段4] money null ,
[字段5] int default 0,
[字段6] Decimal (12,4) default 0,
[字段7] image null ,
)
删除表:
Drop table [表 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号