Je travaille avec des classes wrapper pour ODBC: Ultra Simple DB Class Interface for ODBC (version 1.3) faites par Mark Henri.
MSVC++ 6.0 sous Win2k
J'arrive à passer le contenu de la DB sur un fichier texte par redirection de la sortie cout << [jusque là sans problème]
Quand je vais faire la conversion de sREP_ALIAS sur un tableau des char, le compilateur me geule:
C:\Program Files\Microsoft Visual Studio\VC98\USDBClassPdox10_2\SQLdb01.cpp(90) : error C2664: 'strcpy' : cannot convert parameter 2 from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' to 'const char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
La partie affecté du code est:
Merci et bon week end.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 char buffer [5000]; { // so the recordset is destroyed CSQLRecordset rs( db ); rs << "select REP_ALIAS, DOC_ID, DOC_LASTFIRST," " SEGMENT, BRICK from M_TODOIO"; rs.SetWhere( "REP_ALIAS < 'ZZ'" ); // lt 1 screen full rs.SQLExecDirect(); //init count=0; output=fopen (fileName,"w"); buffer[0]=NULL; while ( rs.SQLFetch() ) { int n = 1; // order is crucial; hence, the ctr string sREP_ALIAS = rs.SQLGetData( n++ ); string sDOC_ID = rs.SQLGetData( n++ ); string sDOC_LASTFIRST = rs.SQLGetData( n++ ); string sSEGMENT = rs.SQLGetData( n++ ); string sBRICK = rs.SQLGetData( n++ ); count+=1; cout << sREP_ALIAS << "," << sDOC_ID << "," << sDOC_LASTFIRST << "," << sSEGMENT << "," << sBRICK << endl; // ceci "imprime" sans problème strcpy(buffer,sREP_ALIAS); // cette conversion se plante avec le message ci dessus !
Partager