|
-
Jul 29th, 2009, 05:47 PM
#1
Thread Starter
Member
Please help - display contents of a database...
Hello All,
I am struggling to display the contents of a database to a "grid" on the device. I need to take all values in the database and display them to the device screen in an "excel" type page.
Here is what I have so far...
c
Code:
conn4 = New SqlCeConnection("password = ''; Data Source = \program files\SmartDeviceProject6\MyDB.sdf")
conn4.Open()
'Select all records
Dim cmd4 As New SqlCeCommand("SELECT * FROM MainDB", conn4)
rdr2 = cmd4.ExecuteReader()
DataGrid1.DataSource = "what do I use here to display contents?"
Thanks all, Magohn
-
Jul 30th, 2009, 01:25 AM
#2
Frenzied Member
Re: Please help - display contents of a database...
Hi
you can put it into a datatable, and use that as your source, or there is a sample in the same article that I just linked Waka to in an earlier question.
Take a look at this and see if it does what you need.
Last edited by petevick; Jul 30th, 2009 at 01:37 AM.
-
Jul 30th, 2009, 11:51 AM
#3
Thread Starter
Member
Re: Please help - display contents of a database...
Hi petevick...
Thank you VERY MUCH!!!! That linked article was perfect. I cant believe I have spent hours trying to do what was accomplished with a simple 'drag n drop'. 
Thank YOU !
-
Jul 31st, 2009, 12:41 PM
#4
Thread Starter
Member
Re: Please help - display contents of a database...
Hi Pete (or anyone else),
First of all - thanks again - the linked doc was a huge help for me and my progress. I have a small follow-up question. The data now works perfectly on my device while in the application. I can add/edit and review all the data in the database on the device.
However, when I exit the application and then return back to the application my previously entered data is gone - its as if the database is reset on exit of the app. Any ideas?
Thanks, Magohn
-
Aug 1st, 2009, 05:55 AM
#5
Frenzied Member
Re: Please help - display contents of a database...
have you got your database in the project to copy over to the device when you deploy?
That sounds like the problem, and you overwrite it every time you deploy your app
-
Aug 6th, 2009, 02:42 PM
#6
Thread Starter
Member
Re: Please help - display contents of a database...
 Originally Posted by petevick
have you got your database in the project to copy over to the device when you deploy?
That sounds like the problem, and you overwrite it every time you deploy your app
Hi Pete,
Yes I have, the issue exists on the device also. I open the app and add data, close the app and then return to it -the data is gone!
I poked around a little and found this info on datagrids (what Im using) :
http://www.functionx.com/vcnet/datab...rydatagrid.htm
If you have used tables in SQL Server, Microsoft Access, Paradox, and other database environments, you probably know that their tables automatically save data as the user changes records and moves through cells. Although it is one of the most regularly used objects of databases in Microsoft Visual .NET, the DataGrid control doesn't inherently provide this functionality, but for a good reason. By default, the DataGrid control is not meant for databases only. When a DataGrid control displays data, it allows a user to enter new data but doesn't save it.
Data entered in a DataGrid is extremely easy to save. This is simply taken care of by calling the Update method of your data adapter.
So I guess all I have to do is figure out how to "update" the datagrid as the writers example is in C++ whereas I am using VB.
Thanks, Magohn
-
Aug 9th, 2009, 07:43 AM
#7
Frenzied Member
Re: Please help - display contents of a database...
The article you looked at is for the full framework - not the compact framework. The original article explained inserting/updating.
-
Aug 18th, 2009, 02:53 PM
#8
Thread Starter
Member
Re: Please help - display contents of a database...
 Originally Posted by petevick
The article you looked at is for the full framework - not the compact framework. The original article explained inserting/updating.
Hi Pete,
Though in the original article I see where it explains adding/editing items I do not see any reference to saving the database on exit from the application - am Imissing something? 
Thanks, Magohn
-
Aug 19th, 2009, 04:04 AM
#9
Frenzied Member
Re: Please help - display contents of a database...
Hi,
the method shown only adds data to the datatable as the tool doesn't generate the code.
After the .endit() do something like
ApplyUpdatesToDatabase()
and then
Code:
Private Sub ApplyUpdatesToDatabase()
Dim sourcedatatable As DataTable = (DirectCast(Me.CustomersBindingSource.Current, DataRowView)).DataView.Table
Dim Customerdatatable As NorthwindDataSet.CustomersDataTable = DirectCast(sourcedatatable, NorthwindDataSet.CustomersDataTable)
Dim ta As New NorthwindDataSetTableAdapters.CustomersTableAdapter
ta.Update(Customerdatatable)
End Sub
That should do it
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|