homepage Welcome to WebmasterWorld Guest from 107.20.129.212
register, login, search, subscribe, help, library, PubCon, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Visit PubCon.com
Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library : Charter : Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
Connect to sdf file with vb
andrewsmd




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

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

 

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
WebmasterWorld ® and PubCon ® are a Registered Trademarks of Pubcon Inc.
© Pubcon Inc. 1996-2012 all rights reserved