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

    [asp.net & vb.net] creare e scrivere sull' ultimo record di un database

    Ciao a tutti forumisti. Come da titolo mi occorreva sapere come riuscire a scrivere su un database.

    Questo è un codice prelevato dalla rete e nonostante sono riuscito a "leggere i dati" con facilità utilizzando il codice con alcune modifiche, non riesco però a scrivere all' interno di un mio DATABASE che ha una lista di indirizzi inseriti in unico CAMPO.



    Imports System.Data.OleDb

    Partial Class Registrazione

    Inherits System.Web.UI.Page
    Dim cn As OleDbConnection
    Dim cmd As OleDbCommand
    Dim dr As OleDbDataReader
    Dim icount As Integer
    Dim str As String

    Protected Sub bInvia_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bInvia.Click

    cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("NOMEDELMIODATABASE.mdb"))
    cn.Open()
    str = "INSERT INTO TABELLA VALUES ('" & tIndirizzo.Text & "')"

    'string stores the command and CInt is used to convert number to string
    cmd = New OleDbCommand(str, cn)

    icount = cmd.ExecuteNonQuery

    ******* 'L' ERRORE E' PROPRIO NELLA STRINGA DI DI SOPRA
    --- Errore di sintassi nell'istruzione INSERT INTO. ---
    OLEDBEXCEPTION NON è STATA GESTITA DAL CODICE UTENTE



    MsgBox(icount)
    'displays number of records inserted

    cn.Close()
    End Sub

    End Class


    SPERO DI ESSERE STAO CHIARO.
    GRAZIE PER L' ATTENZIONE SPERO CHE QUALCUNO MI AIUTI.
    jabjoint

  2. #2
    str = "INSERT INTO TABELLA (nomecampo) VALUES ('" & tIndirizzo.Text & "')"
    "...non è detto che sia tardi se non guardi che ora è..."

  3. #3
    ciao grazie
    jabjoint

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.