Visualizzazione dei risultati da 1 a 5 su 5
  1. #1

    ASP insert in SQL server

    Non riesco a fare un insert inuna tavola SQL... mi inserisce un record vuoto ma non i^dati che gli mando...

    allego la fonte che preleva i dati da un foglio di excel... e poi lo script che li riceve e dovrebbe inserirli nella tabella sql...

    FONTE_______________________________

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>


    <%
    Dim Recordset1
    Dim Recordset1_numRows

    Set Recordset1 = Server.CreateObject("ADODB.Recordset")
    Recordset1.ActiveConnection = MM_riscal_STRING
    Recordset1.Source = "SELECT * FROM area"
    Recordset1.CursorType = 0
    Recordset1.CursorLocation = 2
    Recordset1.LockType = 1
    Recordset1.Open()

    Recordset1_numRows = 0
    %>

    <html>
    <head>
    <title>Documento senza titolo</title>

    <style type="text/css">
    <!--
    .Stile1 {font-family: Verdana, Arial, Helvetica, sans-serif}
    body,td,th {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 10px;
    }
    -->
    </style>
    </head>

    <body>
    <h3 align="center" class="Stile1">Modulo di archiviazione prove di riscaldamento </h3>
    <form action="insert.asp" method="post" name="form1">
    <table width="90%" border="0" align="center" cellpadding="0" cellspacing="2">
    <tr bgcolor="#EBEBEB">
    <td width="25%">Scheda</td>
    <td><input name="scheda" type="text" id="scheda" value="<%=(Recordset1.Fields.Item("scheda").Value) %>"></td>
    </tr>
    <tr>
    <td>Fabb. Nr </td>
    <td><input name="revisione" type="text" id="revisione" value="<%=(Recordset1.Fields.Item("fabbnr").Value) %>"></td>
    </tr>
    <tr bgcolor="#EBEBEB">
    <td>Cliente</td>
    <td><input name="cliente" type="text" id="cliente" value="<%=(Recordset1.Fields.Item("cliente").Value )%>">
    </td>
    </tr>
    </table>


    <table width="90%" border="0" align="center" cellpadding="0" cellspacing="2">
    <tr bgcolor="#FFFFCC">
    <td width="25%">Valori di resistenza OHM</td>
    <td><input name="resistenza_ohm" type="text" id="resistenza_ohm" value="<%=(Recordset1.Fields.Item("resistenza_ohm" ).Value)%>"></td>
    </tr>
    </table>


    <table width="90%" border="0" align="center" cellpadding="0" cellspacing="2">
    <tr bgcolor="#FFFFCC">
    <td width="25%">Intervalli di tempo </td>
    <td><input name="tempo" type="text" id="tempo" value="<%=(Recordset1.Fields.Item("tempo").Value)% >"></td>
    </tr>
    </table>


    <table width="90%" border="0" align="center" cellpadding="0" cellspacing="2">
    <tr bgcolor="#EBEBEB">
    <td width="25%">Resistenza a freddo </td>
    <td width="73%"><input name="resistenza_freddo" type="text" id="resistenza_freddo" value="<%=(Recordset1.Fields.Item("resistenza_fred do").Value)%>"></td>
    </tr>
    <tr>
    <td>Temperatura ambiente </td>
    <td><input name="temperatura_ambiente" type="text" id="temperatura_ambiente" value="<%=(Recordset1.Fields.Item("temperatura_amb iente").Value)%>"></td>
    </tr>
    <tr bgcolor="#EBEBEB">
    <td>Conduttore</td>
    <td><input name="conduttore" type="text" id="conduttore" value="<%=(Recordset1.Fields.Item("Conduttore").Va lue)%>"></td>
    </tr>
    <tr>
    <td>Morsetti</td>
    <td><input name="morsetti" type="text" id="morsetti" value="<%=(Recordset1.Fields.Item("Morsetti").Valu e)%>"></td>
    </tr>
    <tr bgcolor="#EBEBEB">
    <td>Temperatura ambiente allo stacco </td>
    <td><input name="temperatura_ambiente_stacco" type="text" id="temperatura_ambiente_stacco" value="<%=(Recordset1.Fields.Item("Temp_ambiente_s tacco").Value)%>"></td>
    </tr>
    <tr>
    <td>Corrente di prova </td>
    <td><input name="corrente_prova" type="text" id="corrente_prova" value="<%=(Recordset1.Fields.Item("Corrente_prova ").Value)%>"></td>
    </tr>
    <tr bgcolor="#EBEBEB">
    <td>Corrente nominale </td>
    <td><input name="corrente_nominale" type="text" id="corrente_nominale" value="<%=(Recordset1.Fields.Item("Corrente_nomina le").Value)%>"></td>
    </tr>
    <tr>
    <td>Corrente continua </td>
    <td><input name="corrente_continua" type="text" id="corrente_continua" value="<%=(Recordset1.Fields.Item("Corrente_contin ua").Value)%>"></td>
    </tr>
    <tr bgcolor="#EBEBEB">
    <td>Resistenza allo stacco </td>
    <td><input name="resistenza_stacco" type="text" id="resistenza_stacco" value="<%=(Recordset1.Fields.Item("Resistenza_stac co").Value)%>"></td>
    </tr>
    <tr>
    <td>Sovratemperatura alla corrente di prova </td>
    <td><input name="sovratemperatura_corrente_prova" type="text" id="sovratemperatura_corrente_prova" value="<%=(Recordset1.Fields.Item("Sovratemperatur a_corrente_prova").Value)%>"></td>
    </tr>
    <tr bgcolor="#EBEBEB">
    <td>Sovratemperatura alla corrente nominale </td>
    <td><input name="sovratemperatura_corrente_nominale" type="text" id="sovratemperatura_corrente_nominale" value="<%=(Recordset1.Fields.Item("Sovratemperatur a_corrente_nominale").Value)%>"></td>
    </tr>
    <tr>
    <td>Note</td>
    <td><textarea name="note" cols="50" rows="6" id="note" ><%=(Recordset1.Fields.Item("Note").Value)%></textarea></td>
    </tr>
    <tr bgcolor="#EBEBEB">
    <td>Data</td>
    <td><input name="ladata" type="text" id="ladata" value="<%=(Recordset1.Fields.Item("data").Value)%> "></td>
    </tr>
    <tr>
    <td>Collaudatore</td>
    <td><input name="collaudatore" type="text" id="collaudatore" value="<%=(Recordset1.Fields.Item("collaudatore"). Value)%>"></td>
    </tr>
    <tr bgcolor="#EBEBEB">
    <td>Visto</td>
    <td><input name="visto" type="text" id="visto" value="<%=(Recordset1.Fields.Item("visto").Value)% >"></td>
    </tr>
    <tr>
    <td></td>
    <td><input type="submit" name="Submit" value="Archivia Collaudo"></td>
    </tr>
    <tr>
    <td></td>
    <td></td>
    </tr>
    <tr>
    <td></td>
    <td></td>
    </tr>
    <tr>
    <td></td>
    <td></td>
    </tr>
    <tr>
    <td></td>
    <td></td>
    </tr>
    </table>


    </p>


    </p>
    </form>


    </p>
    </body>
    </html>
    <%
    Recordset1.Close()
    Set Recordset1 = Nothing
    %>


    E QUESTO E LO SCRIPT CHE DOVREBBE INSERIRE IN SQL______________________________________________


    <html>
    <head>
    <title></title>
    <script language="javascript">
    function redirect() {
    window.location = "javascript:history.go(-1)";
    }
    function tempo() {
    setTimeout('redirect()', 2000)
    }
    </script>
    <link href="stile.css" rel="stylesheet" type="text/css">
    </head>
    <BODY BGCOLOR="#FFFFFF" leftmargin="10" topmargin="10" marginwidth="0" marginheight="0" onLoad="tempo()">


    <%


    scheda=request.form("scheda")
    revisione=request.form("revisione")
    cliente=request.form("cliente")
    resistenza_ohm=request.form("resistenza_ohm")
    tempo=request.form("tempo")
    resistenza_freddo=request.form("resistenza_freddo" )
    temperatura_ambiente=request.form("temperatura_amb iente")
    conduttore=request.form("conduttore")
    morsetti=request.form("morsetti")
    temperatura_ambiente_stacco=request.form("temperat ura_ambiente_stacco")
    corrente_prova=request.form("corrente_prova")
    corrente_nominale=request.form("corrente_nominale" )
    corrente_continua=request.form("corrente_continua" )
    resistenza_stacco=request.form("resistenza_stacco" )
    sovratemperatura_corrente_prova=request.form("sovr atemperatura_corrente_prova")
    sovratemperatura_corrente_nominale=request.form("s ovratemperatura_corrente_nominale")
    note=request.form("note")
    ladata=request.form("ladata")
    collaudatore=request.form("collaudatore")
    visto=request.form("visto")

    Set Conn = Server.CreateObject("ADODB.Connection")
    Conn.Open "DRIVER={SQL Server};Trusted_Connection=NO;Provider=SQLOLEDB;Da ta Source=UTESRVR1;Initial Catalog=laboratorio;User ID=senkal;Password=yxcvbn"
    'strconn = "Provider=sqlOLEDB;Dsn=laboratorio;User Id=senkal;PASSWORD=yxcvbn;"
    'Set Conn = Server.CreateObject("ADODB.Connection")
    'Conn.open strconn



    SQL = "INSERT INTO collaudi (scheda,revisione,cliente,resistenza_ohm,tempo,res istenza_freddo,temperatura_ambiente,conduttore,mor setti,temperatura_ambiente_stacco,corrente_prova,c orrente_nominale,corrente_continua,resistenza_stac co,sovratemperatura_corrente_prova,sovratemperatur a_corrente_nominale,note,ladata,collaudatore,visto )"

    SQL = SQL&"VALUES('"&scheda&"','"&revisione&"','"&client e&"','"&resistenza_ohm&"','"&tempo&"','"&resistenz a_freddo&"','"&temperatura_ambiente&"','"&condutto re&"','"&morsetti&"','"&temperatura_ambiente_stacc o&"','"&corrente_prova&"','"&corrente_nominale&"', '"&corrente_continua&"','"&resistenza_stacco&"','" &sovratemperatura_corrente_prova&"','"&sovratemper atura_corrente_nominale&"','"&note&"','"&ladata&"' ,'"&collaudatore&"','"&visto&"')"

    Conn.Execute(SQL)



    %>


    </body>

    </html>
    la bistecca alla brace..

  2. #2
    Utente di HTML.it L'avatar di albis
    Registrato dal
    May 2002
    Messaggi
    912
    al posto di
    codice:
    SQL = SQL&"VALUES('"&scheda&"','"&revisione&"','"&cliente&"','"&resistenza_ohm&"','"&tempo&"','"&resistenza_freddo&"','"&temperatura_ambiente&"','"&conduttore&"','"&morsetti&"','"&temperatura_ambiente_stacco&"','"&corrente_prova&"','"&corrente_nominale&"','"&corrente_continua&"','"&resistenza_stacco&"','"&sovratemperatura_corrente_prova&"','"&sovratemperatura_corrente_nominale&"','"¬e&"','"&ladata&"','"&collaudatore&"','"&visto&"')" 
    
    Conn.Execute(SQL)
    scrivi

    codice:
    SQL = SQL&"VALUES('"&scheda&"','"&revisione&"','"&cliente&"','"&resistenza_ohm&"','"&tempo&"','"&resistenza_freddo&"','"&temperatura_ambiente&"','"&conduttore&"','"&morsetti&"','"&temperatura_ambiente_stacco&"','"&corrente_prova&"','"&corrente_nominale&"','"&corrente_continua&"','"&resistenza_stacco&"','"&sovratemperatura_corrente_prova&"','"&sovratemperatura_corrente_nominale&"','"¬e&"','"&ladata&"','"&collaudatore&"','"&visto&"')" 
    Response.Write "|" & SQL & "|" 
    Response.End()
    Conn.Execute(SQL)

    e vedi cosa ti restituisce
    Forza la magica ROMA

  3. #3
    GRAZIE PER LA RISPOSTA.. MI DA ERRORE 500 IL CHE NON MI AIUTA PER NIENTE...... dovrebbe funzionare secondo me... ma non capisco davvero il perchè del perenne errore 500
    la bistecca alla brace..

  4. #4
    Utente di HTML.it L'avatar di Sypher
    Registrato dal
    Jun 2003
    Messaggi
    1,994
    Originariamente inviato da fabiofree
    GRAZIE PER LA RISPOSTA.. MI DA ERRORE 500 IL CHE NON MI AIUTA PER NIENTE...... dovrebbe funzionare secondo me... ma non capisco davvero il perchè del perenne errore 500
    prova a disattivare dalle opzioni avanzate di explorer mostra brevi messaggi HTTP o qualcosa del genere
    La passera non dura perchè Sypher la cattura!

    "No one like us we don't care, we are millwall, super millwall, we are millwall from the DEN"

  5. #5
    Utente di HTML.it L'avatar di albis
    Registrato dal
    May 2002
    Messaggi
    912
    Sul menu Strumenti --> Opzioni Internet --> Avanzate, declicca (togli la spunta) la voce "Mostra messaggi di errore HTTP brevi"
    e poi ricarica la pagina e leggi l'errore
    Forza la magica ROMA

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.