插入时出现内存分配错误 [英] memory allocation error while insert

查看:114
本文介绍了插入时出现内存分配错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人

现在我在使用UTF8和我的程序时遇到了问题,解决方案是使用ODBC 5.1而不是3.5,但是现在我发现了新问题

当我使用以下sql命令插入时

Dear all

now i was having a problem with UTF8 and my program and the sol was to use ODBC 5.1 instead of 3.5 but now i found new problem

when i insert using the following sql command

INSERT INTO users
(UserName, PassWord)
VALUES (?, SHA1(?))



我收到ODBC 5.1错误,内存分配错误!尽管它在ODBC 3.5中工作得很好,但是当我刚删除SHA1时,它又可以工作了?
那我该怎么办?
我尝试了许多其他乐趣.像MD5一样,加密......全部不起作用



i get ODBC 5.1 error memory allocation error !! although it was working so fine in ODBC 3.5 and when i just remove SHA1 , it worked again ??

so what should i do?
i tried many other fun. like MD5 , encrypt ...... all not working

推荐答案

首先,您应该在代码中而不是在SQL中对密码进行哈希处理.为什么?因为您是在代码和SQL Server之间明文"传输密码.中间人攻击可以观察到SQL请求飞越并拉出帐户ID和密码.

您已经发现了不这样做的第二个原因:兼容性.您选择的访问数据库的方法不容许升级.另外,后备数据库可能不支持您想要的哈希函数(您正在使用ODBC来对各种数据库引擎进行通用访问,对吗?)
First, you should be hashing the password in your code, not in the SQL. Why? Because you''re transmitting the password "in the clear" between your code and the SQL server. A man-in-the-middle attack can watch the SQL request fly by and yank out the account id and password.

You already found out about the second reason why you don''t do this: Compatibility. The method you chose to access the database is not tolerate of upgrades. Also, the backing database may not support the hashing function you want (you are using ODBC for generic access to various database engines, correct?)


为MySql跳过ODBC驱动程序并下载 MySql Connector/Net [
Skip ODBC driver for MySql and download MySql Connector/Net[^] native C# driver.

And use MySqlParameter for the job. Do as Dave suggests. Do hashing before INSERT statement.


odbc版本. 3支援sha但是ver. 5产生了这样的问题
odbc ver. 3 support sha but ver. 5 makes such problem


这篇关于插入时出现内存分配错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆