Hi, I have some problem connecting access via vb.net!
I need 3 sub routines to GET, PUT and UPDATE records!
the GET routine works very well
Public Sub db_Get(ByVal Tabella As String, ByVal Campo As String, ByRef Destinazione As String, Optional ByVal Filtro As String = "", Optional ByVal FiltroValue As String = "")
Dim ConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & PercorsoDB & NomeDB
Dim Cn As New OleDbConnection(ConnString)
Cn.Open()
'recupera i dati dal db
Destinazione = ""
Select Case Filtro
Case ""
Dim sql_MC As String = "select * from " & Tabella
Dim cmd_MC As New OleDbCommand(sql_MC, Cn)
Dim dr_MC As OleDbDataReader = cmd_MC.ExecuteReader
Do While dr_MC.Read()
Destinazione = (dr_MC.Item(Campo))
Loop
Case Else
Dim sql_MC As String = "select * from " & Tabella & " where " & Filtro & "=?"
Dim cmd_MC As New OleDbCommand(sql_MC, Cn)
cmd_MC.Parameters.AddWithValue(Filtro, FiltroValue)
Dim dr_MC As OleDbDataReader = cmd_MC.ExecuteReader
Do While dr_MC.Read()
Destinazione = (dr_MC.Item(Campo).ToString)
Loop
End Select
Cn.Close()
End Sub
the PUT routine works very well too
Sub putDB(ByVal t As Margot.Contatto)
If t.FTP.ToString = "" Then t.FTP = "NO"
If t.Fornitore = "" Then t.Fornitore = "NO"
If t.Cliente = "" Then t.Cliente = "NO"
If t.RisorsaInterna = "" Then t.RisorsaInterna = "NO"
If t.EsenteEPAP = "" Then t.EsenteEPAP = "NO"
Dim PercorsoDB As String = "W:\00_00_00 - Programma_Gestione\File_Mdb\"
Dim NomeDB = "Margot.mdb"
Dim a As String = "', '"
Dim ConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & PercorsoDB & NomeDB
Dim Cn As New OleDbConnection(ConnString)
Cn.Open()
If t.Cognome <> "" Then
Dim sql_MC As String = "INSERT INTO Tab_Contatti (Cognome, Nome, Societą, wIndirizzo, wCAP, wCittą, wProvincia, Accesso_FTP_Arcadia, FTP_User, FTP_Pwd,Cliente,Fornitore,EsenteEPAP,Risorsa_Interna, wMail) VALUES ('"
sql_MC &= t.Cognome & a & t.Nome & a & t.Societą & a & t.wIndirizzo & a & t.wCap & a & t.wCittą & a & t.wProvincia & a & t.FTP & a & t.FTP_User & a & t.FTP_Pwd & a & t.Cliente & a & t.Fornitore & a & t.EsenteEPAP & a & t.RisorsaInterna & a & t.wMail & "')"
Dim cmd_MC As New OleDbCommand(sql_MC, Cn)
cmd_MC.ExecuteNonQuery()
Else
Dim sql_MC As String = "INSERT INTO Tab_Contatti (Cognome, Societą, wIndirizzo, wCAP, wCittą, wProvincia, Accesso_FTP_Arcadia, FTP_User, FTP_Pwd,Cliente,Fornitore,EsenteEPAP,Risorsa_Interna, wMail) VALUES ('"
sql_MC &= t.Societą & a & t.Societą & a & t.wIndirizzo & a & t.wCap & a & t.wCittą & a & t.wProvincia & a & t.FTP & a & t.FTP_User & a & t.FTP_Pwd & a & t.Cliente & a & t.Fornitore & a & t.EsenteEPAP & a & t.RisorsaInterna & a & t.wMail & "')"
Dim cmd_MC As New OleDbCommand(sql_MC, Cn)
cmd_MC.ExecuteNonQuery()
End If
Cn.Close()
End Sub
But I can't develop the UPDATE routine
Can someone help me?
tnx
/r