Home > Back-end >  SQL and C BUILDER 6.0 development problem solving?
SQL and C BUILDER 6.0 development problem solving?

Time:10-14

Ask, dear brother, younger brother of the phase I in the use of c + + builder 6.0 in a books management system management system, using a SQL database, on the server using ADOQuery1 DataSetProvider1 ADOtable1 DataSetProvider2 put the table in the library books together, in the client data module joined DCOMConnection1 ClientDataSet1 connect server,
1, on the client side realize to the table in the query operation of library books,
DataModule2 - & gt; ClientDataSet1 - & gt; Active=true;
DataModule2 - & gt; ClientDataSet1 - & gt; The Open ();
AnsiString a="Select * from books in the library Where book number='" + Form1 - & gt; Edit1 - & gt; The Text + "'";
DataModule2 - & gt; ClientDataSet1 - & gt; CommandText=a;
Form1 - & gt; Edit2 - & gt; Text=DataModule2 - & gt; ClientDataSet1 - & gt; FieldByName (" title ") - & gt; The Value;
Returns the result is wrong,,,,,,, what is the reason?
2, on the server with the following language implementation to insert a table of data, can insert the data, but display an error, why?
Form5 - & gt; ADOQuery1 - & gt; Active=false;
Form5 - & gt; ADOQuery1 - & gt; SQL - & gt; The Clear ();
Form5 - & gt; ADOQuery1 - & gt; SQL - & gt; Add (" insert into the administrator information values (' + Form5 - & gt;" Edit1 - & gt; The Text + "', '" + Form5 - & gt; Edit2 - & gt; The Text + "', '" + Form5 - & gt; Edit3 - & gt; The Text + "', '" + Form5 - & gt; Edit4 - & gt; The Text + "', '" + Form5 - & gt; Edit5 - & gt; The Text + "', '" + Form5 - & gt; Edit6 - & gt; The Text + "', '" + Form5 - & gt; Edit7 - & gt; The Text + "')");
Form5 - & gt; ADOQuery1 - & gt; The Open ();
Form5 - & gt; ADOQuery1 - & gt; UpdateRecord ();

CodePudding user response:

How no one to help me??????????

CodePudding user response:

1, ClientDataSet1 not set Active=True or not Open,
2, SQL number field is inconsistent?
Look at the basics

CodePudding user response:

1, is the statement sequence errors,
General operation: Settings - first & gt; Active=false; And then reset the SQL statements; Finally, the Open ();
2, do not return the query results of SQL statement (insert... I can not use ADOQuery1 - & gt; Open (), and change to ADOQuery1 - & gt; ExecSQL ();

CodePudding user response:

Take to return the result of the select to use ADOQuery1 - & gt; The Open ();
And don't take returns the result of the insert, update and use ADOQuery1 - & gt; ExecSQL ();

CodePudding user response:

Are there any other solutions? All this doesn't work,,,, thank you

CodePudding user response:

 

Bool TDM: : query (TADOQuery * ADOQ, String SQL)//used to query the
{
Try {
ADOQ - & gt; Close();
ADOQ - & gt; SQL - & gt; Text=SQL;
ADOQ - & gt; The Open ();
return true;
} the catch (Exception & amp; E) {
Application - & gt; MessageBox ((" SQL operations error [" + E.M essage + "] "). The c_str (), "tip", MB_OK + MB_ICONINFORMATION);
}
ADOQ - & gt; Close();
return false;
}


Bool TDM: : update (String SQL)//insert and update
{

Try {
if (! ADOCon1 - & gt; Connected) ADOCon1 - & gt; The Open ();
ADOCon1 - & gt; BeginTrans ();
ADOCon1 - & gt; Execute (SQL);
ADOCon1 - & gt; CommitTrans ();
return true;
} the catch (const Exception & amp; E) {
ADOCon1 - & gt; RollbackTrans ();
Application - & gt; MessageBox ((" SQL operations error [" + E.M essage + "] "). The c_str (), "tip", MB_OK + MB_ICONINFORMATION);
}
return false;
}

Void initsFeeName ()//take a query returns values into a map
{
String SQL="select the name from t_Tree";
Map M_sFeeName;
M_sFeeName. The clear ();
If (DM - & gt; The query (DM - & gt; ADOQ1, SQL)) {
Int fieldCount=DM - & gt; ADOQ1 - & gt; FieldCount;
Int recordCount=DM - & gt; ADOQ1 - & gt; RecordCount.//rows and columns
Adoint: : _di__Recordset you=DM - & gt; ADOQ1 - & gt; You;
You - & gt; MoveFirst ();
for (int i=0; I & lt; RecordCount. I++) {
For (int j=0; J & lt; FieldCount; J++) {
M_sFeeName [I]=getValueByOle (you - & gt; Fields - & gt; The Item [j] - & gt; Value);
}
You - & gt; MoveNext ();
}
return;
}

}



To contribute to the building

CodePudding user response:

1, on the client side realize to the table in the query operation of library books,
DataModule2 - & gt; ClientDataSet1 - & gt; Active=true;
DataModule2 - & gt; ClientDataSet1 - & gt; The Open ();
AnsiString a="Select * from books in the library Where book number='" + Form1 - & gt; Edit1 - & gt; The Text + "'";
DataModule2 - & gt; ClientDataSet1 - & gt; CommandText=a;
Form1 - & gt; Edit2 - & gt; Text=DataModule2 - & gt; ClientDataSet1 - & gt; FieldByName (" title ") - & gt; The Value;
Returns the result is wrong,,,,,,, what is the reason?
Try to DataModule2 - & gt; ClientDataSet1 - & gt; FieldByName (" title ") - & gt; The Value;
Instead of DataModule2 - & gt; ClientDataSet1 - & gt; FieldByName (" title ") - & gt; AsString;

2, on the server with the following language implementation to insert a table of data, can insert the data, but display an error, why?
Form5 - & gt; ADOQuery1 - & gt; Active=false;
Form5 - & gt; ADOQuery1 - & gt; SQL - & gt; The Clear ();
Form5 - & gt; ADOQuery1 - & gt; SQL - & gt; Add (" insert into the administrator information values (' + Form5 - & gt;" Edit1 - & gt; The Text + "', '" + Form5 - & gt; Edit2 - & gt; The Text + "', '" + Form5 - & gt; Edit3 - & gt; The Text + "', '" + Form5 - & gt; Edit4 - & gt; The Text + "', '" + Form5 - & gt; Edit5 - & gt; The Text + "', '" + Form5 - & gt; Edit6 - & gt; The Text + "', '" + Form5 - & gt; Edit7 - & gt; The Text + "')");
Form5 - & gt; ADOQuery1 - & gt; The Open ();
Form5 - & gt; ADOQuery1 - & gt; UpdateRecord ();
-- will be behind two other Form5 - & gt; ADOQuery1 - & gt; The Open ();
Form5 - & gt; ADOQuery1 - & gt; UpdateRecord ();
Instead of Form5 - & gt; ADOQuery1 - & gt; ExecSQL ();
In addition, if you can, try to list the fields are listed, or sometimes all don't know is which want to corresponding data,

CodePudding user response:

refer to 7th floor SUNXLLEE response:
1, on the client side realize to the table in the query operation of library books,
DataModule2 - & gt; ClientDataSet1 - & gt; Active=true;
DataModule2 - & gt; ClientDataSet1 - & gt; The Open ();
AnsiString a="Select * from books in the library Where book number='" + Form1 - & gt; Edit1 - & gt; The Text + "'";
DataModule2 - & gt; ClientDataSet1 - & gt; CommandText=a;
Form1 - & gt; nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related