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();
|
||||
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);
|
||||
}
|
||||
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();
|
||||
while (!inFile.eof()) {
|
||||
inFile >> title[0] >> title[1] >> title[2] >> title[3] >> title[4];
|
||||
student->setId(title[0]);
|
||||
student->setName(title[1]);
|
||||
student->setSex(title[2]);
|
||||
student->setStuClass(title[3]);
|
||||
student->setStatus(title[4]);
|
||||
addStudent(connection, *student);
|
||||
if (getStudentById(connection, title[0]) == NULL) {
|
||||
student->setId(title[0]);
|
||||
student->setName(title[1]);
|
||||
student->setSex(title[2]);
|
||||
student->setStuClass(title[3]);
|
||||
student->setStatus(title[4]);
|
||||
addStudent(connection, *student);
|
||||
}
|
||||
}
|
||||
printf("成功导入student.txt文件!\n");
|
||||
inFile.close();
|
||||
@ -889,9 +891,11 @@ void importCourseData(_ConnectionPtr connection) {
|
||||
Course* course = new Course();
|
||||
while (!inFile.eof()) {
|
||||
inFile >> title[0] >> title[1];
|
||||
course->setId(title[0]);
|
||||
course->setName(title[1]);
|
||||
addCourse(connection, *course);
|
||||
if (getCourseById(connection, title[0]) == NULL) {
|
||||
course->setId(title[0]);
|
||||
course->setName(title[1]);
|
||||
addCourse(connection, *course);
|
||||
}
|
||||
}
|
||||
printf("成功导入course.txt文件!\n");
|
||||
inFile.close();
|
||||
@ -914,10 +918,12 @@ void importGradeData(_ConnectionPtr connection) {
|
||||
Grade* grade = new Grade();
|
||||
while (!inFile.eof()) {
|
||||
inFile >> title[0] >> title[1] >> title[2];
|
||||
grade->setStuId(title[0]);
|
||||
grade->setCourseId(title[1]);
|
||||
grade->setGrade(title[2]);
|
||||
addGrade(connection, *grade);
|
||||
if (getOnesGrade(connection, title[0], title[1]) == NULL) {
|
||||
grade->setStuId(title[0]);
|
||||
grade->setCourseId(title[1]);
|
||||
grade->setGrade(title[2]);
|
||||
addGrade(connection, *grade);
|
||||
}
|
||||
}
|
||||
printf("成功导入grade.txt文件!\n");
|
||||
inFile.close();
|
||||
|
Loading…
x
Reference in New Issue
Block a user