Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trouble in accessing sql through vc++

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
iam a project trainee.my proj requires me to access db in sql server using vc++.iam able to retrieve records.but ia have probs in updation, insertion and deletion.while updating only if values are of char* datatype the fields are updatedand not for others like int,date,float.insertion gives errors.

the foll is the code that works as the value for the field is of type string:

printf("cheque book request\n");
//update db
//db access
rs.CreateInstance("ADODB.Recordset");

vQry= _bstr_t("select * from cheqbkdet");

try
{
rs->Open(&vQry,(_variant_t)Connection.GetInterfacePtr(),adOpenForwardOnly,adLockOptimistic,adCmdText);
}
catch(...)
{
puts("record does not exist");
}
rs->MoveFirst();

if((!rs->ENDOFFILE) && (rs!=NULL))
{
while (! rs->ENDOFFILE)
{

int acc=atoi((char*)_bstr_t(rs->Fields->GetItem((long)0)->GetValue()));
if (acc==accno)
{
strcpy(status,((char*)_bstr_t(rs->Fields->GetItem((long)2)->GetValue())));
flag=true;
}

rs->MoveNext();
}


}
if (flag==false)
{
printf("\n No cheque deposited for the given account no");
}
else
{
printf("\ncheque status (cleared/ uncleared): %s",status);
}

rs->MoveFirst();
strcpy(status,(char *)_bstr_t(rs->Fields->GetItem("cheqstatus")->GetValue()));
printf("enter the new status");
scanf("%s",status);

rs->Fields->GetItem("cheqstatus")->Value=status;
rs->Update();

i would be grateful if someone could help me with this.
thanx.
ramya.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top