// MySql_fullDlg.cpp : implementation file
//
#include "stdafx.h"
#include <afxsock.h>
#include <stdio.h>
#include <windows.h>
#include <mysql.h>
#include <winbase.h>
#include "MySql_full.h"
#include "MySql_fullDlg.h"
#include ".\mysql_fulldlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Implementation
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
// CMySql_fullDlg dialog
CString str_file2;
CMySql_fullDlg::CMySql_fullDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMySql_fullDlg::IDD, pParent)
, str_ed1(_T(""))
, str_ed2(_T(""))
, str_user(_T("root"))
, str_pass(_T("1"))
, str_base(_T("luki_"))
, str_host(_T("localhost"))
, str_port(_T("3306"))
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CMySql_fullDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, str_ed1);
DDX_Text(pDX, IDC_EDIT2, str_ed2);
DDX_Text(pDX, IDC_EDIT3, str_user);
DDX_Text(pDX, IDC_EDIT4, str_pass);
DDX_Text(pDX, IDC_EDIT5, str_base);
DDX_Text(pDX, IDC_EDIT6, str_host);
DDX_Text(pDX, IDC_EDIT7, str_port);
}
BEGIN_MESSAGE_MAP(CMySql_fullDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDOK, OnBnClickedOk)
ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
ON_BN_CLICKED(IDC_BUTTON3, OnBnClickedButton3)
ON_BN_CLICKED(IDC_BUTTON4, OnBnClickedButton4)
ON_EN_CHANGE(IDC_EDIT2, OnEnChangeEdit2)
ON_EN_CHANGE(IDC_EDIT3, OnEnChangeEdit3)
ON_EN_CHANGE(IDC_EDIT5, OnEnChangeEdit5)
ON_BN_CLICKED(IDC_BUTTON5, OnBnClickedButton5)
ON_BN_CLICKED(IDC_BUTTON6, OnBnClickedButton6)
END_MESSAGE_MAP()
// CMySql_fullDlg message handlers
BOOL CMySql_fullDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CMySql_fullDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CMySql_fullDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this function to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CMySql_fullDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void CMySql_fullDlg::OnBnClickedOk()
{
}
void CMySql_fullDlg::OnBnClickedButton1()
{
UpdateData(TRUE);
// создание стандартной панели выбора файла Open
CFileDialog DlgOpen(TRUE,(LPCSTR)"iso",NULL,OFN_HIDEREADONLY,(LPCSTR)" ISO Files (*.iso) |*.iso||");
// отображение стандартной панели выбора файла Open
if(DlgOpen.DoModal()==IDOK)
{
// создание объекта и открытие файла для чтения
//CStdioFile File(DlgOpen.GetPathName(),CFile::modeRead|CFile::typeBinary);
str_ed1 = DlgOpen.GetPathName();
//File.Close();
}
UpdateData(FALSE);
}
void CMySql_fullDlg::OnBnClickedButton2()
{
UpdateData(TRUE);
// создание стандартной панели выбора файла Open
CFileDialog DlgOpen(TRUE,(LPCSTR)"abs",NULL,OFN_HIDEREADONLY,(LPCSTR)" ABSFiles (*.abs) |*.abs||");
// отображение стандартной панели выбора файла Open
if(DlgOpen.DoModal()==IDOK)
{
// создание объекта и открытие файла для чтения
//CStdioFile File(DlgOpen.GetPathName(),CFile::modeRead|CFile::typeBinary);
str_ed2 = DlgOpen.GetPathName();
str_file2 = DlgOpen.GetPathName();
//File.Close();
}
UpdateData(FALSE);
}
/*CString title = GetField("Title", str);
CString key_word = GetField("key_word", str);
CString rubric = GetField("Rubric", str);
CString bbk = GetField("Local classification", str);
CString udc = GetField("UDC classification", str);
CString data4 = GetField("Data", str);
CString series = GetField("Title series", str);
CString publisher = GetField("Publisher", str);
CString property = GetField("Property", str);
CString code_language = GetField("Code-language", str);
*/
CString GetField1(CString fdxxx, CString sprav, CString per_fd, CString fd1)
{
CString f = " ";
while (sprav != ""){
CString fld = sprav.Mid(0, 3);
CString len = sprav.Mid(3, 4);
int len1 = atoi(len);
CString pos = sprav.Mid(7, 5);
int pos1 = atoi(pos);
if (fld == fdxxx)
{
f = per_fd.Mid(pos1, len1);
CString res = "";
while (f.Find(31) >= 0)
{
CString c = f.Mid(f.Find(31) + 1,1);
f = f.Mid(f.Find(31)+2);
if ( fd1.Find(c) >= 0 )
{
if (f.Find(31) >=0) res = res + f.Mid(0,f.Find(31)) + " ";
else res = res + f.Mid(0,f.Find(30)) + " ";
}
}
f = res;
break;
}
sprav = sprav.Mid(12);
}
return f;
}
int GetRecords(CString aR[], int ac, CString record)
{
CString marker = record.Mid(0,24);
int pos0 = atoi(marker.Mid(12,5));
CString sprav = record.Mid(24, pos0 - 24);
CString per_fd = record.Mid(pos0);
CString f = " ";
int i = 0;
while ((sprav != "") && (i <= ac))
{
CString fld = sprav.Mid(0, 3);
CString len = sprav.Mid(3, 4);
int lenfld = atoi(len);
CString pos = sprav.Mid(7, 5);
int posfld = atoi(pos);
f = per_fd.Mid(posfld, lenfld);
while (f.Find(31) >= 0)
f = f.Mid(0, f.Find(31)) + "$" + f.Mid(f.Find(31)+ 1);
f = f.Mid(0, f.Find(30));
f = fld + f;
sprav = sprav.Mid(12);
aR[i] = f;
i++;
}
return 0;
}
CString GetF(CString fd, CString str)
{
CString str_fd = "";
if ( str.Find(fd) > 0)
{
str_fd = str.Mid(str.Find(fd)+ fd.GetLength());
if ( str_fd.Find("$") >= 0 )
str_fd = str_fd.Mid(0, str_fd.Find("$"));
}
return str_fd;
}
CString GetFieldEx(CString fd, CString record)
{
int cnt = 0;
CString spr = record.Mid(24, record.Find(31) - 24);
cnt = spr.GetLength()/12 + 1;
CString *aRecords = new CString[cnt];
GetRecords(aRecords, cnt, record);
CStdioFile File2(str_file2, CFile::modeRead|CFile::typeBinary);
CString s_attr[50];
int i = 0;
while (File2.GetPosition() != File2.GetLength())
{
CString str = "";
File2.ReadString(str);
if (str.Trim() == "<" + fd + ">")
{
File2.ReadString(str);
while (str.Trim() != "</" + fd + ">")
{
//add
if ((!str.IsEmpty()) && (str.Trim().GetLength() != 0))
{
s_attr[i] = str.Trim();
i++;
}
//w
File2.ReadString(str);
}
break;
}
}
CString field = " ";
CString marker = record.Mid(0,24);
int pos0 = atoi(marker.Mid(12,5));
CString sprav = record.Mid(24, pos0 - 24);
CString per_fd = record.Mid(pos0);
for(int s = 0; s < i; s++)
for(int v = 0; v < cnt; v++)
{
if ( s_attr[s].Mid(0,2) == "m_")
{
int pos_m = atoi(s_attr[s].Mid(2,1));
field = aRecords[v].Mid(pos_m - 1,1);
break;
}
else if(s_attr[s].GetLength() == 3)
{
if (s_attr[s].Mid(0,1) == aRecords[v].Mid(0,1))
if ((s_attr[s].Mid(1,1) == aRecords[v].Mid(1,1)) || (s_attr[s].Mid(1,1) == "-"))
if ((s_attr[s].Mid(2,1) == aRecords[v].Mid(2,1)) || (s_attr[s].Mid(2,1) == "-"))
field += "$" + aRecords[v].Mid(3).Trim() + "$";
}
else
{
if (s_attr[s].Mid(0,1) == aRecords[v].Mid(0,1))
if ((s_attr[s].Mid(1,1) == aRecords[v].Mid(1,1)) || (s_attr[s].Mid(1,1) == "-"))
if ((s_attr[s].Mid(2,1) == aRecords[v].Mid(2,1)) || (s_attr[s].Mid(2,1) == "-"))
if ((s_attr[s].Mid(3,1) == aRecords[v].Mid(3,1)) || ((s_attr[s].Mid(3,1) == "#") && (aRecords[v].Mid(3,1) == " ")) || ((s_attr[s].Mid(3,1) == "-")))
if ((s_attr[s].Mid(4,1) == aRecords[v].Mid(4,1)) || ((s_attr[s].Mid(4,1) == "#") && (aRecords[v].Mid(4,1) == " ")) || ((s_attr[s].Mid(4,1) == "-")))
{
CString str_e = s_attr[s].Mid(5);
CString str_curr = "";
CString str_f = "";
CString str_fields = aRecords[v];
while (str_e.GetLength() > 0)
{
str_curr = str_e.Mid(str_e.Find("$"),2);
str_e = s_attr[s].Mid(s_attr[s].Find(str_curr) + str_curr.GetLength());
CString str_fd = GetF(str_curr, aRecords[v]);
CString as = str_curr + str_fd;
str_fields = str_fields.Mid(0,str_fields.Find(as)) + str_fields.Mid(str_fields.Find(as)+as.GetLength());
if (!str_fd.IsEmpty())
{
CString rz = str_e.Mid(0, str_e.Find("$"));
if (rz.Find("{")>= 0) rz = rz.Mid(0,rz.Find("{")) + rz.Mid(rz.Find("{")+1);
if (rz.Find("}")>= 0) rz = rz.Mid(0,rz.Find("}")) + rz.Mid(rz.Find("}")+1);
str_f = str_f + str_fd + rz;
}
else
{//если следующий элемент пустой, то не продолжаем
break;
}
str_e = str_e.Mid(str_e.Find("$"));
}
str_f.Trim();
if ((str_f.Mid(str_f.GetLength()-1) == ",") || (str_f.Mid(str_f.GetLength()-1) == "("))
str_f = str_f.Mid(0,str_f.GetLength()-2);
if (!str_f.Trim().IsEmpty())
field += "$" + str_f.Trim() + "$";
}
}
}
File2.Close();
int p = 0;
if (field.Find("'", p)>= 0)
{
field = field.Mid(0,field.Find("'",p)) + "''" + field.Mid(field.Find("'",p)+1);
p = field.Find("'", p) + 2;
}
delete [] aRecords;
//field.OemToAnsi();
//field.MakeLower();
//field.AnsiToOem();
return field.Trim();
}
CString GetField(CString fd, CString record)
{
//CStdioFile File2(str_ed2, CFile::modeRead|CFile::typeBinary);
//File2.Close();
CString field = " ";
CString marker = record.Mid(0,24);
int pos0 = atoi(marker.Mid(12,5));
CString sprav = record.Mid(24, record.Find(31) - 24);
CString per_fd = record.Mid(pos0);
if (fd == "Author")
{
field = GetField1("700", sprav, per_fd, "a,g,c").Mid(0,500);
}else if (fd == "Title")
{
field = GetField1("200", sprav, per_fd, "a,h,i").Mid(0,500);
}else if (fd == "key_word")
{
field = GetField1("610", sprav, per_fd, "a");
}else if (fd == "Rubric")
{
field = GetField1("600", sprav, per_fd, "a");//
}else if (fd == "Local classification")
{
field = GetField1("686", sprav, per_fd, "a");//
}else if (fd == "UDC classification")
{
field = GetField1("675", sprav, per_fd, "a");//
}else if (fd == "Data")
{
field = GetField1("210", sprav, per_fd, "d");//
field = field.Trim();
if (atoi(field) == 0) field = "0";
}else if (fd == "Title series")
{
field = GetField1("225", sprav, per_fd, "a,h,i");//
}else if (fd == "Publisher")
{
field = GetField1("210", sprav, per_fd, "c");//
}else if (fd == "Property")
{
field = "0";//
}else if (fd == "Code-language")
{
field = GetField1("101", sprav, per_fd, "a");//
}
return field;
}
MYSQL mysql;
MYSQL_RES *res;
MYSQL_ROW row;
void CMySql_fullDlg::OnBnClickedButton3()
{
UpdateData(1);
if (str_ed1 == "")
{
MessageBox("Не выбран файл с записями", "Error", MB_ICONERROR | MB_OK);
return;
}
if (str_ed2 == "")
{
MessageBox("Не выбран файл с атрибутами", "Error", MB_ICONERROR | MB_OK);
return;
}
CStdioFile File1(str_ed1, CFile::modeRead|CFile::typeBinary);
if (!mysql_init (&mysql)) abort();
int port = atoi(str_port);
if (!(mysql_real_connect(&mysql, (char*)(LPCTSTR)str_host, (char*)(LPCTSTR)str_user, (char*)(LPCTSTR)str_pass, (char*)(LPCTSTR)str_base, port , NULL , 0)))
{
MessageBox(mysql_error(&mysql), "Error", MB_ICONERROR | MB_OK);
return;
}
if (mysql_select_db(&mysql,(char*)(LPCTSTR)str_base))
{
MessageBox(mysql_error(&mysql), "Error", MB_ICONERROR | MB_OK);
return;
}
char p[] = "SET NAMES 'cp1251'";
if (mysql_query(&mysql, (char*)p))
{
MessageBox(mysql_error(&mysql), "Error", MB_ICONERROR | MB_OK);
return;
}
//идем по файлу и вставляем записи в таблицу
//while (File1.E)
while (File1.GetPosition() != File1.GetLength())
{
CString str = "";
CString str_iso = "";
char szBuffer[1];
int nActual = File1.Read( szBuffer, sizeof( szBuffer ) );
while (szBuffer[0] != 29)
{
if (szBuffer[0] == 92)
{
str_iso += szBuffer[0];
}
str += szBuffer[0];
str_iso += szBuffer[0];
nActual = File1.Read( szBuffer, sizeof( szBuffer ) );
}
str += szBuffer[0];
str_iso += szBuffer[0];
/*int p = 0;
while (str.Find("\", p)>=0)
{
p = str.Find("\", p);
str = str.Mid(0, 2) + "\" + str.Mid(2);
p+=2;
}*/
//str.OemToAnsi();
//AfxMessageBox(str);
if (str.GetLength() > 4000)
{
MessageBox("Размер записи слишком большой. Запись не будет загружена.", "Error", MB_ICONERROR | MB_OK);
continue;
}
CString query = "INSERT INTO records VALUES(";
query = query + "'" + GetFieldEx("Author", str) + "',";
//MessageBox(GetFieldEx("Author", str), "Error", MB_ICONERROR | MB_OK);
query = query + "'" + GetFieldEx("Title", str) + "',";
//MessageBox(GetFieldEx("Title", str), "Error", MB_ICONERROR | MB_OK);
query = query + "'" + GetFieldEx("Key_word", str) + "',";
//MessageBox(GetFieldEx("Key_word", str), "Error", MB_ICONERROR | MB_OK);
query = query + "'" + GetFieldEx("Rubric", str) + "',";
//MessageBox(GetFieldEx("Rubric", str), "Error", MB_ICONERROR | MB_OK);
query = query + "'" + GetFieldEx("Local classification", str) + "',";
//MessageBox(GetFieldEx("Local classification", str), "Error", MB_ICONERROR | MB_OK);
query = query + "'" + GetFieldEx("UDC classification", str) + "',";
//MessageBox(GetFieldEx("UDC classification", str), "Error", MB_ICONERROR | MB_OK);
//query = query + "0,";
query = query + GetField("Data", str) + ",";
query = query + "'" + GetFieldEx("Title series", str) + "',";
//MessageBox(GetFieldEx("Title series", str), "Error", MB_ICONERROR | MB_OK);
query = query + "'" + GetFieldEx("Publisher", str) + "',";
//MessageBox(GetFieldEx("Publisher", str), "Error", MB_ICONERROR | MB_OK);
query = query + "'" + GetFieldEx("Property", str) + "',";
query = query + "'" + GetFieldEx("Code-language", str) + "',";
query = query + "'" + GetFieldEx("Local number", str) + "',";
query = query + "'" + GetFieldEx("Bib - level", str) + "',";
query = query + "'" + GetFieldEx("ISBN", str) + "',";
query = query + "'" + GetFieldEx("Place publication", str) + "',";
query = query + "'" + GetFieldEx("Material type", str) + "',";
query = query + "'" + GetFieldEx("Title parallel", str) + "',";
query = query + "'" + GetFieldEx("Note", str) + "',";
query = query + "'" + GetFieldEx("Doc ID", str) + "',";
query = query + "'" + GetFieldEx("Abstract", str) + "',";
query = query + "'" + GetFieldEx("Stock number", str) + "',";
int p = 0;
if (str_iso.Find("'", p)>= 0)
{
str_iso = str_iso.Mid(0,str_iso.Find("'",p)) + "''" + str_iso.Mid(str_iso.Find("'",p)+1);
p = str_iso.Find("'", p) + 2;
}
query = query + "'" + str_iso + "')";
//MessageBox(query, "Error", MB_ICONERROR | MB_OK);
//continue;
//'1','2','3','4','5','6',7,'8','9','10','11','12')";
/*CString author = GetField("Author", str);
CString title = GetField("Title", str);
CString key_word = GetField("key_word", str);
CString rubric = GetField("Rubric", str);
CString bbk = GetField("Local classification", str);
CString udc = GetField("UDC classification", str);
CString data4 = GetField("Data", str);
CString series = GetField("Title series", str);
CString publisher = GetField("Publisher", str);
CString property = GetField("Property", str);
CString code_language = GetField("Code-language", str);*/
if (mysql_query(&mysql,(char*)(LPCTSTR)query))
{
MessageBox(mysql_error(&mysql), "Error", MB_ICONERROR | MB_OK);
continue;
}
}
//(char*)(LPCTSTR)
/*if (mysql_query(&mysql,"INSERT INTO records2 VALUES('1','2','3','4','5','6',7,'8','9','10','11','12')"))
{
MessageBox(mysql_error(&mysql), "Error", MB_ICONERROR | MB_OK);
return;
}*/
mysql_free_result(res);
mysql_close(&mysql);
//
File1.Close();
MessageBox("Все записи загружены!", "ОК", MB_OK);
UpdateData(0);
//File2.Close();
}
void CMySql_fullDlg::OnBnClickedButton4()
{
UpdateData(1);
if (!mysql_init (&mysql)) abort();
int port = atoi(str_port);
if (!(mysql_real_connect(&mysql, (char*)(LPCTSTR)str_host, (char*)(LPCTSTR)str_user, (char*)(LPCTSTR)str_pass, (char*)(LPCTSTR)str_base, port , NULL , 0)))
{
MessageBox(mysql_error(&mysql), "Error", MB_ICONERROR | MB_OK);
return;
}
if (mysql_select_db(&mysql,(char*)(LPCTSTR)str_base))
{
MessageBox(mysql_error(&mysql), "Error", MB_ICONERROR | MB_OK);
return;
}
if (mysql_query(&mysql,"DELETE FROM records"))
{
MessageBox(mysql_error(&mysql), "Error", MB_ICONERROR | MB_OK);
return;
}
mysql_free_result(res);
mysql_close(&mysql);
MessageBox("Все записи удалены!", "ОК", MB_OK);
UpdateData(0);
}
void CMySql_fullDlg::OnEnChangeEdit2()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
void CMySql_fullDlg::OnEnChangeEdit3()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
void CMySql_fullDlg::OnEnChangeEdit5()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
void CMySql_fullDlg::OnBnClickedButton5()
{
UpdateData(1);
//Создаем базу
if (!mysql_init (&mysql)) abort();
int port = atoi(str_port);
if (!(mysql_real_connect(&mysql, (char*)(LPCTSTR)str_host, (char*)(LPCTSTR)str_user, (char*)(LPCTSTR)str_pass, NULL, port , NULL , 0)))
{
MessageBox(mysql_error(&mysql), "Error", MB_ICONERROR | MB_OK);
return;
}
char p[] = "SET NAMES 'cp1251'";
if (mysql_query(&mysql, (char*)p))
{
MessageBox(mysql_error(&mysql), "Error", MB_ICONERROR | MB_OK);
return;
}
CString qw = "CREATE DATABASE " + str_base;
CString qwu = "USE " + str_base;
if (mysql_query(&mysql, (char*)(LPCTSTR)qw))
{
MessageBox(mysql_error(&mysql), "Error", MB_ICONERROR | MB_OK);
return;
}
if (mysql_query(&mysql, (char*)(LPCTSTR)qwu))
{
MessageBox(mysql_error(&mysql), "Error", MB_ICONERROR | MB_OK);
return;
}
if (mysql_query(&mysql,"CREATE TABLE records(\\
Author VARCHAR(700), \\
Title VARCHAR(800),\\
Key_word VARCHAR(800),\\
Rubric VARCHAR(800),\\
BBK VARCHAR(150),\\
UDC VARCHAR(150),\\
Data4 INT(11),\\
Series VARCHAR(300),\\
Publisher VARCHAR(200),\\
Property VARCHAR(500),\\
Code_language VARCHAR(300),\\
Local_number VARCHAR(100),\\
Bib_level VARCHAR(10),\\
ISBN VARCHAR(100),\\
Place_publication VARCHAR(100),\\
Material_type VARCHAR(100),\\
Title_parallel VARCHAR(300),\\
Note VARCHAR(1500),\\
DocID VARCHAR(200),\\
Abstract VARCHAR(1500),\\
Stock_number VARCHAR(200),\\
Iso VARCHAR(4500)\\
)DEFAULT CHARSET cp1251"))
{
MessageBox(mysql_error(&mysql), "Error", MB_ICONERROR | MB_OK);
return;
}
mysql_free_result(res);
mysql_close(&mysql);
UpdateData(0);
MessageBox("База данных создана!", "ОК", MB_OK);
}
void CMySql_fullDlg::OnBnClickedButton6()
{
UpdateData(1);
if (!mysql_init (&mysql)) abort();
int port = atoi(str_port);
if (!(mysql_real_connect(&mysql, (char*)(LPCTSTR)str_host, (char*)(LPCTSTR)str_user, (char*)(LPCTSTR)str_pass, NULL, port , NULL , 0)))
{
MessageBox(mysql_error(&mysql), "Error", MB_ICONERROR | MB_OK);
return;
}
CString del_base = "DROP DATABASE " + str_base;
if (mysql_query(&mysql, (char*)(LPCTSTR)del_base))
{
MessageBox(mysql_error(&mysql), "Error", MB_ICONERROR | MB_OK);
return;
}
mysql_free_result(res);
mysql_close(&mysql);
UpdateData(0);
MessageBox("База данных удалена!", "ОК", MB_OK);
}