CString sql; 
sql="SELECT* FROM Login WHERE Uname="+m_Name+""; 
sql.Format("select * from login where Uname = '%s'",m_Name);  这个操作成功了!
CString sqlinto;
sqlinto.Format("insert into Login(Uname,Upasswd,power)valuse('%s','%s',0)",m_Name,m_Pwd);
theApp.m_pCon->Execute((_bstr_t)sqlinto,NULL,adCmdText);
这个像数据库中插入数据就显示下面的错误!Runtime error! This application has requested the runtime to terminate it in an unusual way.Please contact 
the application's support team for more information. 
出现一个这样的对话框,是为什么啊!

解决方案 »

  1.   

    CString sqlinto; 
    sqlinto.Format("insert into Login(Uname,Upasswd,power)valuse('%s','%s',0)",m_Name,m_Pwd); 
    m_pRs=theApp.m_pCon->Execute((_bstr_t)sqlinto,NULL,adCmdText); 
    主要的问题还是在sql语句中,首先应该使用.format其次就是这里面的数据的输入的方法
    ("insert into Login(Uname,Upasswd,power)valuse('%s','%s',0)",m_Name,m_Pwd); 如果像这样
    sqlinto.Format("insert into Login(Uname,Upasswd,power)values("+m_Name+","+m_Pwd+",0)");就会出错,本人虽然知道是这样解决 但是想知道为什么,不知道哪位大侠能给出分析!
      

  2.   

    可以把两种打印出来的sql对比一下,以及放到数据库的查询分析器就知道哪个对,哪个错
    对于sql,字符串要用''包含