• 0

Need Help With VB 2008 Express And Database


Question

I'm writing an App in Visual Basic 2008 Express to better manage Installation data for some of our equipment. Currently it is contained in an XLSX sheet that is 90 colums wide, 120 rows long, and 4 tabs deep.

I've got the UI almost completed, and I've defined a datasource on my desktop as a SQL compact .sdf database, have set the database up, and have added some data to it, plus have defined some controls on my app to point to the colums in the DB and pull data...it works so far as a dumb app, but now I'm stuck.

Question 1: How can I make it so my .sdf DB gets packaged with the app when I build it, so that it can be distributed?

Question 2: If I debug my program or even run it, I can edit and change data inside the app, and it looks like it gets cached, but when I exit debug or the app and go look at the data in the database, nothing is changed. I know nothing about sql, so trying to manually connect to the database is difficult for me, and I assumed that setting the "datasource update mode" to "OnPropertyChange" or "OnValidation" for each field was supposed to update the value in the DB each time it was updated, but it looks like it isn't working.

Would appreciate some help with this, and if someone wants to take the time to get database updating and packaging working, I'd be willing to paypal some $ for your time.

I can provide the project if you want to take a look at it.

Thanks in advance.

Edit: Think I found out how to deploy the SQL express DB with my app using a video found here: http://msdn.microsoft.com/en-us/vbasic/bb466226.aspx Just need to figure out how to connect the DB and

modify data back to it.

post-26332-1249618595_thumb.jpg

Attached is a shot of the program so far. Basically the goal is to have a Field Service Engineer select the Site he is at from the drop down at the top right, and then it loads data into the 2 tabs on the form for that location. I want it so that whenever data is changed on the form, it is written back to the database, which is located in the applications path (USMCData.sdf)

I'm trying a few different things, here is the code for the serial numbers update section:

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

		Dim cmd As New SqlCeCommand("SELECT DISTINCT CurrentReaderSN FROM USMCInstall", connStr)

		connStr.Open()
		SerialNumber.Text = cmd.UpdatedRowSource

		Dim conADO As ADODB.Connection
		conADO = New ADODB.Connection
		Dim strConnection As String



		conADO = New ADODB.Connection

		strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source='C:\Documents and Settings\erichardson\Desktop\New Folder (2)\USMC Maintenance Program\USMC Installation Management\USMC Installation Management\USMCData.sdf'"



		conADO.ConnectionString = strConnection

		conADO.Open()

		Dim conn As New OleDb.OleDbConnection
		Dim targetRow As DataRow

		conn.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;|DataDirectory|\USMCData.sdf"
		conn.Open()
		Dim ds As New DataSet
		Dim da As OleDb.OleDbDataAdapter
		Dim sql As String

		sql = "Update CurrentReaderSN set"
		da = New OleDb.OleDbDataAdapter(sql, conn)
		targetRow = ds.Tables("USMCInstall").Rows.Find(Me.SerialNumber.Text)

		targetRow.Item("CurrentReaderSN") = SerialNumber.Text
		MsgBox("Updated Rec")

yet I can't get any of these to work so far.

Edited by SirEvan
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

WEll i figured it out, something was screwed up in where the data was pulling from and now i got it fixed.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.