I test my code in example project(IAPConnect )
in appui.cpp
case EIAPConnectCmdConnectGPRS:
{
iEngine->SetConnectionPreferences(ECommDbBearerGPRS, EFalse,1);
iEngine->ConnectL();
iAppContainer->DrawNow();
break;
}

SetConnectionPreferences(
TUint aBearer,
TBool aDialog,
TUint32 aIapId)
{
iPref.SetDirection(ECommDbConnectionDirectionOutgoing);
if (aDialog)
{
iPref.SetDialogPreference(ECommDbDialogPrefPrompt);
}
else
{
iPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
}
iPref.SetIapId(aIapId);
iPref.SetBearerSet(aBearer);
iPref.SetDirection(ECommDbConnectionDirectionOutgoing);

When calling the function, it can't create a connection. why?