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...:)
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
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
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
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 :)
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
Re: SQL CE - Write contents to a MsgBox ?
Ahhh- I see - thanks much - I will give it a shot! :)
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....
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
Re: SQL CE - Write contents to a MsgBox ?
Thank you techgnome - appreciate it!