Hi Albert,
If your form isn't modal than =sqldisconnect(0) will fire immidiately after form is instantiated making connection handle invalid.
>
>I have a programm that connects me to a database and than starts a form
>public p_connection
>p_connection = -1
>STORE SQLSTRINGCONNECT('dsn=maxdblokal;uid=xxx;pwd=xxx;DATABASE=xxx') to p_connection
>if p_connection > 0
> messagebox(str(p_connection)) = 1 !!!
> do form xyz
> =sqldisconnect(0)
>endif
>When calling
>l_sqlcmd = "select * from tablename"
>l_error = SQLEXEC(p_connection,l_sqlcmd,"alldata")
>browse
>in the init event of the form xyz everything is ok !
>
>but when calling the same at the click event of a command button in the form i get a error
>connection handle not valid ????????????????????????
>the debugger show me, that p_connection = 1 ??????????????
>
--sb--