Home Page
Articoli
Tips & Tricks
News
Forum
Archivio Forum
Blogs
Sondaggi
Rss
Video
Utenti
Chi Siamo
Contattaci
Username:
Password:
Login
Registrati ora!
Recupera Password
Home Page
Stanze Forum
SQL Server 2000/2005/2008, Express, Access, MySQL, Oracle
Popolamento automatico database
martedì 01 giugno 2010 - 14.27
Elenco Threads
Stanze Forum
Aggiungi ai Preferiti
Cerca nel forum
katana
Profilo
| Newbie
3
messaggi | Data Invio:
mar 1 giu 2010 - 14:27
prima di tutto ciao a tutti
ho un problema abbastanza urgente da risolvere.
ho una tabella creata con Microsoft SQL Server con 3 campi;
tramite un ciclo do while creo diciamo i miei dati in vb dopodichè dovrei spararli dentro nella mia tabella. il problema è che questo do while ha un contatore e finchè non raggiunge il valore 15.000.000 non si ferma. in pratica devo generare 15.000.000 di record . la sub funziona solo che è troppo lenta in 14 ore ha riempito soltanto 800.000 record.. qualcuno sa aiutarmi a velocizzare questo processo?!
Private Sub GeneraRecord()
Dim dataAdapter As SqlDataAdapter
dataAdapter = New SqlDataAdapter("SELECT * FROM Posizioni ORDER BY IMEI", sqlConn)
Dim dataSet As DataSet
dataSet = New DataSet
Try
dataAdapter.Fill(dataSet)
Do While nr < 15000000
imei = imei + 1
If imei > 9999 Then
imei = 0
End If
lat = lat + 0.1
If lat > 90 Then
lat = 0
End If
lon = lon + 0.1
If lon > 80 Then
lon = 0
End If
times = times + 1
If times > 9999999999 Then
times = 0
End If
vel = vel + 0.1
If vel > 20 Then
vel = 0
End If
tipoe = tipoe + 1
If tipoe > 99 Then
tipoe = 0
End If
nr = nr + 1
Dim cb As New SqlCommandBuilder(dataAdapter)
Dim newTestRow As DataRow = dataSet.Tables(0).NewRow()
newTestRow(0) = imei
newTestRow(1) = lat
newTestRow(2) = lon
newTestRow(3) = times
newTestRow(4) = vel
newTestRow(5) = tipoe
dataSet.Tables(0).Rows.Add(newTestRow)
dataAdapter.Update(dataSet.Tables(0))
Loop
sqlConn.Close()
nr = 32768
Catch ex As Exception
MsgBox("errore")
End Try
End Sub
carloalberto
Profilo
| Junior Member
166
messaggi | Data Invio:
mar 1 giu 2010 - 15:13
prova a spostare il tutto in una stored ... conto sia piu veloce
ciao
katana
Profilo
| Newbie
3
messaggi | Data Invio:
mar 1 giu 2010 - 16:11
ok ma come faccio a tradurre questo dentro una stored?! so crearla una stored ma non riesco a tradurre tutta questa sub dentro una stored su sql server...
per esempio
imei=imei+1
if imei >9999 then
imei =0
end if
come diventerebbe dentro la stored?!
carloalberto
Profilo
| Junior Member
166
messaggi | Data Invio:
mar 1 giu 2010 - 16:17
...
>imei=imei+1
>if imei >9999 then
>imei =0
>end if
...
declare @imei
set @imei=@imei+1
if @imei>9999 begin
set @imei=0
end
ciao
Torna su
Stanze Forum
Elenco Threads
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?
Dopo esserti registrato potrai chiedere
aiuto sul nostro
Forum
oppure aiutare gli altri
Consulta le
Stanze
disponibili.
Registrati ora !