积极答复者
microsoft visual c++runtime library runtime error

问题
-
microsoft visual c++runtime library
runtime error
program:D:\C++\test\select\Release\select.exe
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more informatinon.上面是错误的信息,D:\C++\test\select是我新建的C++的MFC项目目录,想实现的是用ADO方式往数据库的表中插入一条数据,SQL语句对,但执行SQL语句时就出现了上面的错误,帮忙解决啊,为了这问题,昨晚都没睡好
光在杨
答案
-
光在杨,
您好!您的第一个问题已经解决了,请您再开个新帖问第二个问题。我们将会尽力为您解决问题。
蒋晟,谢谢您的帮助!
Lucy
Lucy Liu [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已标记为答案 光在扬 2011年1月4日 13:11
-
Debug模式下看看那一行出错,把附近的代码贴出来
你不会没有写异常处理吧
The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
Visual C++ MVP- 已标记为答案 光在扬 2010年12月28日 10:41
- 取消答案标记 光在扬 2010年12月28日 10:41
- 已标记为答案 lucy-liuModerator 2011年1月3日 6:53
-
把异常抓下来看看是什么错误
为什么open放在try里面,而Execute和Close不放呢
The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
Visual C++ MVP- 已标记为答案 光在扬 2010年12月28日 10:36
- 取消答案标记 光在扬 2010年12月28日 11:15
- 已标记为答案 lucy-liuModerator 2011年1月3日 6:53
全部回复
-
Debug模式下看看那一行出错,把附近的代码贴出来
你不会没有写异常处理吧
The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
Visual C++ MVP- 已标记为答案 光在扬 2010年12月28日 10:41
- 取消答案标记 光在扬 2010年12月28日 10:41
- 已标记为答案 lucy-liuModerator 2011年1月3日 6:53
-
void insert::OnButton2()
{
// TODO: Add your control notification handler code here
_ConnectionPtr m_pConnection;
try
{
//创建连接对象实例
m_pConnection.CreateInstance("ADODB.Connection");
//设置连接字符串
CString strConnect="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\C++\\test\\select\\test.mdb;Persist Security Info=False";
//使用Open方法连接数据库
m_pConnection->Open((_bstr_t)strConnect,"","",adModeUnknown);
}
catch(_com_error e)
{
AfxMessageBox(e.Description());
}
UpdateData();
CString sql1;
CString sql2;
sql2="select * from Student;";
sql1.Format("insert into Student values('%s','%s','%s',%d)",m_Sno,m_Sname,m_Sex,m_Sage);
// AfxMessageBox(sql1);
m_pConnection->Execute((_bstr_t)sql1,NULL,adCmdText);//就是这一行的问题
// AfxMessageBox(sql1);
m_pConnection->Close();
m_adodc2.SetRecordSource(sql2);
m_adodc2.Refresh();
UpdateData(TRUE);
}现在是有时能插入进去,有时出现上面的错误,不知怎么改才能使它稳定,谢谢!
光在杨 -
把异常抓下来看看是什么错误
为什么open放在try里面,而Execute和Close不放呢
The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
Visual C++ MVP- 已标记为答案 光在扬 2010年12月28日 10:36
- 取消答案标记 光在扬 2010年12月28日 11:15
- 已标记为答案 lucy-liuModerator 2011年1月3日 6:53
-
想再请你帮个忙:就是怎样实现学生表Student(Sno,Sname,Ssex,Sage)的增加删除修改啊,要写代码详细点啊,(ADO+Access+test数据库的Student表+ADO控件+DataGrid控件)下面的实现删除的功能,但没实现,有错误,实现插入的功能已经实现了的。请高手帮忙!
插入的功能:void insert::OnButton2()
{
_ConnectionPtr m_pConnection;
try
{
//创建连接对象实例
m_pConnection.CreateInstance("ADODB.Connection");
//设置连接字符串
CString strConnect="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\C++\\test\\select\\test.mdb;Persist Security Info=False";
//使用Open方法连接数据库
m_pConnection->Open((_bstr_t)strConnect,"","",adModeUnknown);
UpdateData();
CString sql1;
CString sql2;
sql2="select * from Student;";
sql1.Format("insert into Student values('%s','%s','%s',%d)",m_Sno,m_Sname,m_Sex,m_Sage);
m_pConnection->Execute((_bstr_t)sql1,NULL,adCmdText);
m_pConnection->Close();
m_adodc2.SetRecordSource(sql2);
m_adodc2.Refresh();
m_Sno="";
m_Sname="";
m_Sex="";
m_Sage=NULL;
UpdateData(FALSE);
}
catch(_com_error e)
{
AfxMessageBox(e.Description());
}
}删除的功能按钮(错误,没实现,语法没错误)
void Cdelete::OnButton1()
{
// TODO: Add your control notification handler code here
_ConnectionPtr m_pConnection;
try
{
//创建连接对象实例
m_pConnection.CreateInstance("ADODB.Connection");
//设置连接字符串
CString strConnect="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\C++\\test\\select\\test.mdb;Persist Security Info=False";
//使用Open方法连接数据库
m_pConnection->Open((_bstr_t)strConnect,"","",adModeUnknown);
CString sql2,sql1;
// sql2="delete from Student where Sno=";
// sql2+="'"+m_value+"'";
sql2.Format("delete from Student where Sno='%s'",m_value);
m_pConnection->Execute((_bstr_t)sql2,NULL,adCmdText);
AfxMessageBox(sql2);m_pConnection->Close();
sql1="select * from Student";
m_ADODELETE.SetRecordSource(sql1);
m_ADODELETE.Refresh();
UpdateData(FALSE);
}
catch(_com_error e)
{
AfxMessageBox(e.Description());
}
}
光在杨 -
光在杨,
您好!您的第一个问题已经解决了,请您再开个新帖问第二个问题。我们将会尽力为您解决问题。
蒋晟,谢谢您的帮助!
Lucy
Lucy Liu [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已标记为答案 光在扬 2011年1月4日 13:11