2022-06-07 16:20 1、executeSql更改adBSTR为adVarChar,解决值宽度问题 2、导入文件函数添加存在检测,防止产生主键重复
This commit is contained in:
parent
3c613ad5ef
commit
b90b852560
@ -15,7 +15,7 @@ _RecordsetPtr executeSql(_ConnectionPtr connection, const char* sql, vector<stri
|
|||||||
size_t size = v->size();
|
size_t size = v->size();
|
||||||
for (size_t i = 0; i < size; i++)
|
for (size_t i = 0; i < size; i++)
|
||||||
{
|
{
|
||||||
_ParameterPtr p = command->CreateParameter("var" + i, adBSTR, adParamInput, sizeof((*v)[i].c_str()), (*v)[i].c_str());
|
_ParameterPtr p = command->CreateParameter("var" + i, adVarChar, adParamInput, sizeof((*v)[i]), (*v)[i].c_str());
|
||||||
command->Parameters->Append(p);
|
command->Parameters->Append(p);
|
||||||
}
|
}
|
||||||
return command->Execute(NULL, NULL, long(0));
|
return command->Execute(NULL, NULL, long(0));
|
||||||
|
32
Menu.cpp
32
Menu.cpp
@ -861,12 +861,14 @@ void importStudentData(_ConnectionPtr connection) {
|
|||||||
Student* student = new Student();
|
Student* student = new Student();
|
||||||
while (!inFile.eof()) {
|
while (!inFile.eof()) {
|
||||||
inFile >> title[0] >> title[1] >> title[2] >> title[3] >> title[4];
|
inFile >> title[0] >> title[1] >> title[2] >> title[3] >> title[4];
|
||||||
student->setId(title[0]);
|
if (getStudentById(connection, title[0]) == NULL) {
|
||||||
student->setName(title[1]);
|
student->setId(title[0]);
|
||||||
student->setSex(title[2]);
|
student->setName(title[1]);
|
||||||
student->setStuClass(title[3]);
|
student->setSex(title[2]);
|
||||||
student->setStatus(title[4]);
|
student->setStuClass(title[3]);
|
||||||
addStudent(connection, *student);
|
student->setStatus(title[4]);
|
||||||
|
addStudent(connection, *student);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
printf("成功导入student.txt文件!\n");
|
printf("成功导入student.txt文件!\n");
|
||||||
inFile.close();
|
inFile.close();
|
||||||
@ -889,9 +891,11 @@ void importCourseData(_ConnectionPtr connection) {
|
|||||||
Course* course = new Course();
|
Course* course = new Course();
|
||||||
while (!inFile.eof()) {
|
while (!inFile.eof()) {
|
||||||
inFile >> title[0] >> title[1];
|
inFile >> title[0] >> title[1];
|
||||||
course->setId(title[0]);
|
if (getCourseById(connection, title[0]) == NULL) {
|
||||||
course->setName(title[1]);
|
course->setId(title[0]);
|
||||||
addCourse(connection, *course);
|
course->setName(title[1]);
|
||||||
|
addCourse(connection, *course);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
printf("成功导入course.txt文件!\n");
|
printf("成功导入course.txt文件!\n");
|
||||||
inFile.close();
|
inFile.close();
|
||||||
@ -914,10 +918,12 @@ void importGradeData(_ConnectionPtr connection) {
|
|||||||
Grade* grade = new Grade();
|
Grade* grade = new Grade();
|
||||||
while (!inFile.eof()) {
|
while (!inFile.eof()) {
|
||||||
inFile >> title[0] >> title[1] >> title[2];
|
inFile >> title[0] >> title[1] >> title[2];
|
||||||
grade->setStuId(title[0]);
|
if (getOnesGrade(connection, title[0], title[1]) == NULL) {
|
||||||
grade->setCourseId(title[1]);
|
grade->setStuId(title[0]);
|
||||||
grade->setGrade(title[2]);
|
grade->setCourseId(title[1]);
|
||||||
addGrade(connection, *grade);
|
grade->setGrade(title[2]);
|
||||||
|
addGrade(connection, *grade);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
printf("成功导入grade.txt文件!\n");
|
printf("成功导入grade.txt文件!\n");
|
||||||
inFile.close();
|
inFile.close();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user