|
-
Jun 18th, 2009, 10:56 AM
#1
Thread Starter
Member
SQL CE - Write contents to a MsgBox ?
Hello All,
Thanks for the help so far. I now have my app talking to an SQL CE database and I am able to insert data and confirm the data is in the table.
Presently I am using a simple while loop to go thru all the contents of the database and display the integers to the device screen. This results in a MsgBox being displayed seperately for each value.
What is the easiest way to display to the screen the contents of the database all at once? I am not too worried about displaying distinct rows or columns yet, if somebody could provide a way to "SELECT * FROM MyDB" and display it to the screen on one screen I can figure the rest out form there.
Thanks guys - Appreciate it...
-
Jun 18th, 2009, 11:17 AM
#2
Re: SQL CE - Write contents to a MsgBox ?
loop through the data, concatenate the data you want together, then display it in the msgbox....
There isn't a simple, one shot command that will do it for you.
-tg
-
Jun 18th, 2009, 11:39 AM
#3
Thread Starter
Member
Re: SQL CE - Write contents to a MsgBox ?
Thank you techgnome...here is how I am doing it so far:
(VB 2008)
Code:
While rdr.Read
val1 = rdr.GetValue(0)
'so I am assuming I would add an array here and store the values? But I would still have an issue of how to display the array contents all at one time. Is there a better solution to using a MsgBox? Perhaps using the SQL table to display?
MsgBox(val1)
End While
Thanks all, Magohn
-
Jun 18th, 2009, 11:51 AM
#4
Re: SQL CE - Write contents to a MsgBox ?
no... no array... just this:
Code:
Dim val1 As String = ""
do While rdr.Read
val1 &= rdr.GetValue(0).toString
Loop
MessageBox.Show (val1)
-tg
-
Jun 18th, 2009, 03:19 PM
#5
Thread Starter
Member
Re: SQL CE - Write contents to a MsgBox ?
Thank you techgnomw - it works great!
Is there anyway to not use a MsgBox but instead display the contnents to something like a "mini" excel sheet ? Kind of a visual represntation of the DB itself showing the cols + rows?
If not - thanks for this anyways
-
Jun 18th, 2009, 03:56 PM
#6
Re: SQL CE - Write contents to a MsgBox ?
you'd have to build a form with a grid on it... then send the data to the grid (at that point, you wouldn't need to loop, jsut set the datasource of the grid to the datatable) and display the form....
-tg
-
Jun 18th, 2009, 04:07 PM
#7
Thread Starter
Member
Re: SQL CE - Write contents to a MsgBox ?
Ahhh- I see - thanks much - I will give it a shot!
-
Jun 18th, 2009, 04:33 PM
#8
Thread Starter
Member
Re: SQL CE - Write contents to a MsgBox ?
Im back already...
I added a datagrid to my form and tried this :
conn4 = New SqlCeConnection("password = ''; Data Source = \program files\SmartDeviceProject6\MyDB.sdf")
DataGrid1.DataSource(conn4)
but I get the following error on build :
Property access must assign to the property or use its value.
Sorry for the newb questions....
-
Jun 18th, 2009, 04:35 PM
#9
Re: SQL CE - Write contents to a MsgBox ?
Datasource is a property.... and it's going to want to take something that implements IEnumerable or IList - I know that all jsut went over your head (half the time it goes over mine too)... what you need to do is execute your query and get a datatable out of it.... then set that to the DataSource property.... Might want to take a look at the Databaser FAQ & Tutorials thread from some quick help on getting started with that.
-tg
-
Jun 18th, 2009, 04:59 PM
#10
Thread Starter
Member
Re: SQL CE - Write contents to a MsgBox ?
Thank you techgnome - appreciate 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
|