标题:[求助]Runtime error on visual c++!!
只看楼主
srzdy888
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2007-4-16
 问题点数:0 回复次数:1 
[求助]Runtime error on visual c++!!

CUer类的代码如下:
// User.cpp: implementation of the CUser class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Library.h"
#include "User.h"
#include "ADOConn.h"
#include "iostream.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CUser::CUser()
{

}

CUser::~CUser()
{

}

CString CUser::GetuserName()
{
return userName;
}
void CUser::SetuserName(CString Uname)
{
userName=Uname;
}


CString CUser::Getpassword()
{
return password;
}
void CUser::Setpassword(CString Upwd)
{
password=Upwd;
}
int CUser::HaveUser(CString name,CString password)
{
ADOConn m_ADOConn;
m_ADOConn.OnInitADOConn();
CString sql;
sql.Format("SELECT*FROM [user] WHERE 用户名='%s' AND 密码='%s'", name,password);
_RecordsetPtr m_pRecordset;
m_pRecordset=m_ADOConn.GetRecordSet((_bstr_t)sql);
if(m_pRecordset->adoEOF)
return -1;
else
return 1;
m_ADOConn.ExitConnect();
}
int CUser::HaveName(CString name)
{
ADOConn m_AdoConn;
m_AdoConn.OnInitADOConn();
CString sql;
sql.Format("SELECT*FROM [user] WHERE 用户名='%s'",name);
_RecordsetPtr m_pRecordset;
m_pRecordset=m_AdoConn.GetRecordSet((_bstr_t)sql);
if(m_pRecordset->adoEOF)
return -1;
else
return 1;
m_AdoConn.ExitConnect();

}
//添加
void CUser::sql_insert()
{
ADOConn m_AdoConn;
m_AdoConn.OnInitADOConn();
_bstr_t vSQL;
vSQL="INSERT INTO [user] VALUES('" +userName+"','"+ password +"')";
m_AdoConn.ExecuteSQL(vSQL);

m_AdoConn.ExitConnect();
m_AdoConn.ExitConnect();
}
//删除
void CUser::sql_delete(CString username)
{
ADOConn m_AdoConn;
m_AdoConn.OnInitADOConn();
CString sql;
sql.Format("delete from [user] where 用户名='%s'",username);
m_AdoConn.ExecuteSQL((_bstr_t)sql);
m_AdoConn.ExitConnect();
}
void CUser::sql_updatepwd(CString username)
{
ADOConn m_AdoConn;
m_AdoConn.OnInitADOConn();
_bstr_t vSQL;
vSQL="UPDATE Czyxxb SET Pwd='"+password+"' WHERE CzyName="+" '"+username+"'";
m_AdoConn.ExecuteSQL(vSQL);
m_AdoConn.ExitConnect();

}
在添加的窗体下调用的代码如下:
void CAdd_user_dlg::Onaddok()
{
// TODO: Add your control notification handler code here
UpdateData(true);
if(m_name=="")
{
MessageBox("请输入用户名","图书系统");
return;
}

if(m_pwd=="")
{
MessageBox("请输入密码","图书系统");
return;
}
if(m_pwd1=="")
{
MessageBox("请确认密码","图书系统");
return;
}
if(m_pwd!=m_pwd1)
{
MessageBox("两次密码不同","图书系统");
return;
}
CUser xxb;

if(xxb.HaveName(m_name)==1)// .Havename(name)==1)
{
MessageBox("用户以存在,请重新输入","图书系统系统");
return;
}
xxb.SetuserName(m_name);// .SetUserName(m_name);
xxb.Setpassword(m_pwd);// .SetPwd(m_pwd);


xxb.sql_insert();// .sql_insert();
CDialog::OnOK();


}


希望各位大侠能帮一下忙!
小弟水平不够,还是无非看出来!
搜索更多相关主题的帖子: visual Runtime 
2007-04-20 12:50
song4
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:38
帖 子:1533
专家分:4
注 册:2006-3-25
得分:0 
1.越界
2.无空间

嵌入式 ARM 单片机 驱动 RT操作系统 J2ME LINUX  Symbian C C++ 数据结构 JAVA Oracle 设计模式 软件工程 JSP
2007-04-21 08:50



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-133435-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.501707 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved