database and structs
-
hi all! again i need help from the experts :) can someone please help me out in how to access the database (ms sql server 05) and the result (each record) will be placed in a struct. hope someone can help and provide some sample codes. thanks! also another question.. i have a pointer to an array of structs... i would like to create another set (a smaller array) of pointer array based from that struct so i can delete the original array... how can i do this? thanks for all your help! newbie :)
-
hi all! again i need help from the experts :) can someone please help me out in how to access the database (ms sql server 05) and the result (each record) will be placed in a struct. hope someone can help and provide some sample codes. thanks! also another question.. i have a pointer to an array of structs... i would like to create another set (a smaller array) of pointer array based from that struct so i can delete the original array... how can i do this? thanks for all your help! newbie :)
You may want to start by deciding what database access technology you're going to use... For Microsoft possibilities, see: Data Access Technologies Road Map[^] Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
You may want to start by deciding what database access technology you're going to use... For Microsoft possibilities, see: Data Access Technologies Road Map[^] Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
Hi Mark. Tnx for the reply. im going to use ado. i have this sample code already... which returns only a single record. what i am doing is i just get the values of the fields i need and assign it to a variable. szSQL.Format(_T("select * from table where key='101'"); hr = pRS.CreateInstance(__uuidof(Recordset)); if (FAILED(hr)) return false; if (!pRS->adoEOF) { pFields = pRS->Fields; pField = pFields->Item[_T("id")]; _variant_t var = pField->Value; szID = TrimBSTR(var.bstrVal).copy(); pField = pFields->Item[_T("count")]; var = pField->Value; szCnt = TrimBSTR(var.bstrVal).copy(); } now what i am not sure how to do is how to map the result of the query to structs if the return is multiple records. i would like to have the results of the query be stored in an array of structs. do i do the same thing of accessing each fields and creating the struct. i was hoping there is an easier way. thanks! newbie :)