|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Member
Iscritto dal: Jul 2009
Messaggi: 102
|
[ASP] riempire correttamente mdb
ciao a tutti.
ho bisogno di creare un database .mdb che deve gestire circa 40.000 record: ID,valore,x,y lo riempo con uno script in asp: Codice:
<html> <script language="javascript" runat="server"> function rand(){ j=Math.round(Math.random()*100); var tmp; if (j>=0 && j<=80) tmp=1; if (j>=81 && j<=84) tmp=2; if (j>=85 && j<=88) tmp=3; if (j>=89 && j<=92) tmp=4; if (j>=93 && j<=96) tmp=5; if (j>=97 && j<=98) tmp=6; if (j>=99 && j<=100) tmp=7; return tmp; } </script> <% set cn = Server.CreateObject("ADODB.Command") cn.ActiveConnection = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("database\mappa.mdb") cn.CommandText = "DELETE * FROM map" cn.CommandType = 1 cn.CommandTimeout = 0 cn.Prepared = true cn.Execute() set cn = nothing Set cn=Server.CreateObject("ADODB.Connection") cn.connectionstring = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("database\mappa.mdb") cn.Open y=0 for c=1 to 40000 sql="INSERT INTO map (ID,valore,x,y) VALUES ('"& c & "','" & rand() & "','" & int(x) & "','" & int(y) & "')" cn.execute sql x=x+1 if (x=200) then x=0 y=y+1 end if next set cn = nothing response.write "database finito" %> </html> cioe tipo da 4204 a 4632 e con altrettanti salti dopo.. da cosa e dovuto ?? ho gia provato a settare l' ID come chiave primaria e tutte le altre possibili soluzioni, ma nnt. aiutatemi pls |
![]() |
![]() |
![]() |
#2 | |
Senior Member
Iscritto dal: Sep 2004
Messaggi: 3967
|
Quote:
sembra che tu debba inserire solo numeri nelle righe, ma passi la sql come se fossero stringhe perchè racchiudi i values tra singoli apici ('" & pippo & "') . Inoltre, leggo che hai settato ID come chiave primaria: in questo caso non dovresti specificare l'inserimento della chiave primaria nella sql a meno che non sia assente sulla tabella. e poi: nel campo "valore" ti trovi invece con ciò che ti aspetti ?
__________________
Dai wafer di silicio nasce: LoHacker... il primo biscotto Geek ![]() |
|
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 21:16.