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.
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.