Oppure

Loading
02/05/12 10:36
piter123
salve, scarico una tabella di dati da sql server 2005 express con il seguente codice


Dim cnn As New ADODB.Connection
cnn.Open _
"Provider =sqloledb ;" & _
"Data Source=xx.xxx.xxx.xx\SQLEXPRESS;" & _
"Initial Catalog=Nomedb;" & _
"Persist Security Info=True;" & _
"User ID=User;" & _
"Password=Pass;"

FormS1.Ado.ConnectionString = cnn
FormS1.Ado.RecordSource = "SELECT * FROM Nometab"
FormS1.Ado.CommandType = adCmdText
FormS1.Ado.Refresh

cnn.close

nel corso dell'esecuzione del programma mi capita di dover scaricare nuovamente la tabelle e alla riesecuzione della routine sopra descritta mi compae l'errore -2147467259 METODO 'REFRESH' DELL'OGGETTO 'IADODC' NON RIUSCITO.

se poi modifico il codice aggiungendo on error sembra risolverlo almeno in parte anche se mi compare un fastidioso msgbox "errore connessione" che una volta confermato continua la routine di seguito descritta e riscarica la tabella di sql.

on error goto errore
dim NUMERRORE
Dim cnn As New ADODB.Connection
cnn.Open _
"Provider =sqloledb ;" & _
"Data Source=xx.xxx.xxx.xx\SQLEXPRESS;" & _
"Initial Catalog=Nomedb;" & _
"Persist Security Info=True;" & _
"User ID=User;" & _
"Password=Pass;"

FormS1.Ado.ConnectionString = cnn
FormS1.Ado.RecordSource = "SELECT * FROM Nometab"
FormS1.Ado.CommandType = adCmdText
FormS1.Ado.Refresh

if Ricarica=true and NUMERRORE<>0 then
FormS1.Ado.Refresh
end if

cnn.close

errore:
NUMERRORE=err.number
resume next

Esiste un sistema più nobile per risolvere il mio problema o al massimo è possibile eliminare l'msgbox che dice "Errore connessione" ?

Grazie
aaa