Welcome to WebmasterWorld Guest from 54.145.246.183

Forum Moderators: ocean10000

Connect to sdf file with vb

   
8:50 pm on Nov 8, 2011 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



I've done a lot with regular (mdf) sql databases but never anything with sdf files. When I run this code, I get no error, but if I check the database, nothing get's inserted. Any ideas?

Try
Dim connStr As New SqlCeConnection("Data Source=" & Application.StartupPath & "\Database1.sdf;")

'the sql syntax
Dim sql = "INSERT INTO Cowboys(CowboyLastName, CowboyFirstName, ContactInfo, Headers, Heelers) " & _
"Values('" & lastName & "', '" & firstName & "', '" & contactInfo & "', '" & header & "', '" & heeler & "')"

Dim cmd_All_Data As New SqlCeCommand(sql, connStr)
connStr.Open()
cmd_All_Data.ExecuteNonQuery()
connStr.Close()
Catch ex As Exception
success = False
output.Text = ex.ToString
End Try
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month