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
App. WinForms / WPF .NET
Applicazione per smart device... non effettua l'insert into su sdf
mercoledì 20 febbraio 2008 - 15.00
Elenco Threads
Stanze Forum
Aggiungi ai Preferiti
Cerca nel forum
wwwdavide
Profilo
| Newbie
2
messaggi | Data Invio:
mer 20 feb 2008 - 15:00
Salve a tutti!
Sto sbattendo la testa con un progetto per smat device.
Dopo essermi creato un nuovo proetto e un db sdf usando sql ce o provato a leggere ed inserire i dati.
Il mio problema è nel inserimento che non mi da errori ma non inserisce nulla sul db,
vi scrivo il codice.. HELP!!!!!!!!!
----------------dal bottone 2 avvio una insert di prova-----------------
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim value As Integer
value = SqlString("INSERT INTO [Prova] ([Col1]) VALUES ('provaOK')")
End Sub
Public Function SqlString(ByVal stringaSQL As String) As Integer
-----------creo e apro la connessione------------
Dim conn As System.Data.SqlServerCe.SqlCeConnection = Nothing
Dim returnValue As Integer
Try
conn = New System.Data.SqlServerCe.SqlCeConnection("Data Source =" _
+ (System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.GetName.CodeBase) _
+ ("\Database.sdf;" _
+ ("Password =" + """xxxx"";"))))
Dim comm As System.Data.SqlServerCe.SqlCeCommand = New System.Data.SqlServerCe.SqlCeCommand
comm.Connection = conn
conn.Open()
------------inizio l'inserimento---------------------
Dim trans As System.Data.SqlServerCe.SqlCeTransaction
trans = conn.BeginTransaction()
'Inizia la transazione
comm.Transaction = trans
comm.CommandText = stringaSQL
comm.ExecuteNonQuery()
'eseguo la transazione
trans.Commit()
Finally
'chiudiamo sempre le connessioni!
conn.Close()
End Try
SqlString = returnValue
End Function
.... ho anche utilizzato questo sistema....
al posto di trans
Dim cmd As System.Data.SqlServerCe.SqlCeCommand = conn.CreateCommand()
cmd.CommandText = stringaSQL
HELPPPPPPPPPPPP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
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 !