Home > Software engineering >  Vc odbc mysql how to implement a delete tables in the database?
Vc odbc mysql how to implement a delete tables in the database?

Time:10-15

M_DB. The ExecuteSQL (drop table + name of the table).
Why complains, should how to implement

CodePudding user response:

Did you connected

CodePudding user response:

reference 1st floor boylafong response:
did you connected

Even on!

CodePudding user response:

What is the error code?

CodePudding user response:

M_DB. The ExecuteSQL (" drop table table name ");
The table name corresponding exist?
Table name corresponding table not system tables,
The current connection database corresponding user has the authority to delete table?
.

CodePudding user response:

Have permission? Drop table requires permissions

CodePudding user response:

What kind of permissions, now is such, if only write delete this sentence, can be implemented; But I put the table names are recorded in a database table, now want to do is to put the name of the table of the whole record to delete and then put the name of the table corresponds to the table also delete
Cstrings TABLE;
DtuStr=m_pdtuSet - & gt; M_Dtu_num;
TABLE=m_pdtuSet - & gt; M_Tablename;
If (m_dtuimei!=DtuStr)
{
M_pdtuSet - & gt; MoveNext ();
If (m_pdtuSet - & gt; IsEOF ())
{
MessageBox (" this tb_dtu DTU number in the table does not exist!" );
}

}
The else/exist/delete
{

M_pdtuSet - & gt; The Delete ();
M_pdtuSet - & gt; Requery ();
Cstrings TABLEDELE;
TABLEDELE="DROP TABLE" + TABLE;
M_DB. The ExecuteSQL (TABLEDELE);
}

CodePudding user response:

refer to 6th floor yxxwgs response:
what kind of permissions, now is such, if only write delete this sentence, can be implemented; But I put the table names are recorded in a database table, now want to do is to put the name of the table of the whole record to delete and then put the name of the table corresponds to the table also delete
Cstrings TABLE;
DtuStr=m_pdtuSet - & gt; M_Dtu_num;
TABLE=m_pdtuSet - & gt; M_Tablename;
If (m_dtuimei!=DtuStr)
{
M_pdtuSet - & gt; MoveNext ();
If (m_pdtuSet - & gt; IsEOF ())
{
MessageBox (" this tb_dtu DTU number in the table does not exist!" );
}

}
The else/exist/delete
{

M_pdtuSet - & gt; The Delete ();
M_pdtuSet - & gt; Requery ();
Cstrings TABLEDELE;
TABLEDELE="DROP TABLE" + TABLE;
M_DB. The ExecuteSQL (TABLEDELE);
}
you less space? TABLEDELE="DROP TABLE" + TABLE;

CodePudding user response:

Add a space also realization not to delete the

CodePudding user response:

refer to the eighth floor yxxwgs response:
add Spaces are not achieve them delete
debugged ah, look at what is the content of the TABLEDELE, take the SQL statements out to the database using the same login name operation to see what results

CodePudding user response:

SQL statements are right, is if not delete (1) m_pdtuSet - & gt; The Delete (); M_pdtuSet - & gt; Requery (); Direct execution (2) cstrings TABLEDELE;
TABLEDELE="DROP TABLE" + TABLE; M_DB. The ExecuteSQL (TABLEDELE); Is possible to delete table, if you execute the former cannot delete table; Or to perform 2, executed after 1, then 2, 1 cannot achieve, an error is a dialog box with x, there is no other, master who know where is wrong?

There is another issue of database operations, the consult, the contents of the database table is change, when a record in a table is about ten minutes, I will delete the record, when the interface people click on the button would like to add a record in the table, but click don't frequently, that is to say, the table may be an empty table, but I want to be real-time meter reading, like a table with a value in the device number hair message, I now the code is as follows, when the table is empty table will pop-up dialog prompt effective storage range "" try to cross data, how can let the program does not prompt
this?If (m_pdtuSet - & gt; IsEOF ())
{
return;
}
M_pdtuSet - & gt; MoveFirst ();
while (! M_pdtuSet - & gt; IsEOF ())
{
DataSend (m_Num, m_Data);
LastTime=m_pdtuSet - & gt; M_creatTime;
NowTime=CTime: : GetCurrentTime ();
Int m_nHour=nowTime. GetHour ();
///hour////////////////////////////////////////////////////////////////
CTimeSpan span=nowTime - lastTime.//calculate the current system time and the interval of time t1
Int iMin=span. GetTotalMinutes ();//get a total of how many minutes
If (iMin> 10)
{
M_pdtuSet - & gt; The Delete ();
M_pdtuSet - & gt; Requery ();
}
Sleep (200);
M_pdtuSet - & gt; MoveNext ();
}
M_pdtuSet - & gt; Close ();
The delete m_pdtuSet;
  • Related