SQL插入和C ++问题 [英] SQL Insert and C++ Problem
本文介绍了SQL插入和C ++问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
此代码运行,但未插入新记录.我究竟做错了什么?该应用程序设置为通过".
This code runs but is not inserting a new record. What am I doing wrong? The app is set to PASS.
#include "stdafx.h"
#include <stdio.h>
#include <iostream>
#include <string>
#include <conio.h>
#include <fstream>
#include <windows.h>
#include <winsock.h>
#include <c:\\mysql\\include\\mysql.h>
using namespace std;
int main()
{
MYSQL_RES *res_set;
MYSQL* conn;
MYSQL_ROW RED;
conn = mysql_init(NULL);
if (mysql_real_connect(conn,"urlock.db.5513143.hostedresource.com","VendorCheck","Reader1234","urlock",0,NULL,0) !=0)
{
mysql_query(conn,"SELECT COUNT(*) FROM tblURL WHERE IP = ''192.168.1.1'' And Status = ''Active''");
my_ulonglong i = 0;
res_set = mysql_store_result(conn);
my_ulonglong numrows = mysql_num_rows(res_set);
RED = mysql_fetch_row(res_set);
if (atoi(RED[i]) == 1)
{
printf("PASS: %s\n",RED[i]);
mysql_query(conn,"INSERT INTO tblURLAccess (URL,Count) VALUES (''192.168.1.1'',''1''");
}
else
{
printf("FAIL: %s\n",RED[i]);
}
}
else
cout << "Conn Failed!" <<endl;
system("PAUSE");
return 0;
}
推荐答案
请不要重新发布您的问题,Abhinav已经为您回答了上一个问题.
mysql插入问题 [
Please don''t repost your question, already Abhinav gave you answer for your previous question.
mysql Insert Question[^]
That line should be like below
mysql_query(conn,"INSERT INTO tblURLAccess (IP,Count) VALUES (''192.168.1.1'',''1'')");
顺便说一句,总是提到错误消息.
BTW always mention the error message.
这篇关于SQL插入和C ++问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文