Hi, I have a problem trying to capture data from a database to a label. I am trying to display a list of values from my database when i press a button. Can anyone help me out?

This is my code for my database
[ CODE]Dim strDBFileName As String
strDBFileName = "\My Documents\CDRecord.sdf"

If File.Exists(strDBFileName) Then
End If

Dim connStr As String = _
"Data Source = \My Documents\CDRecord.sdf; Password = pass1234;"

Dim engine As New SqlCeEngine(connStr)

' Instantiate SqlCeConnection to create connection with the database
Dim mysqlconnection As New SqlCeConnection _
("Data source = " & strDBFileName & "; Password = pass1234;")

'Instantiate the SQLCeCommand
Dim sqlCreateTable As SqlCeCommand = mysqlconnection.CreateCommand()
Dim sqlInsertRow1 As SqlCeCommand = mysqlconnection.CreateCommand()
Dim sqlInsertRow2 As SqlCeCommand = mysqlconnection.CreateCommand()
Dim sqlInsertRow3 As SqlCeCommand = mysqlconnection.CreateCommand()
Dim sqlInsertRow4 As SqlCeCommand = mysqlconnection.CreateCommand()

sqlCreateTable.CommandText = _
"CREATE TABLE CDRecord (SerialNo nvarchar(4) Not Null, CDTitle nvarchar(50) Not Null, ArtisteName nvarchar(100) Not Null, MusicGenres nvarchar(10) Not Null, Band nvarchar(10) Not Null, Price nvarchar(50) Not Null, Remarks nvarchar(30) Not Null, Level nvarchar(2) Not Null, Zone nvarchar(6) Not Null, CONSTRAINT PK_CDRecord PRIMARY KEY (SerialNo))"

sqlInsertRow1.CommandText = _
"INSERT INTO CDRecord VALUES ('1','The Fame Monster', 'Lady Gaga', 'Pop', 'Solo', '25.5', 'Available', 'L1', 'Blue')"
sqlInsertRow2.CommandText = _
"INSERT INTO CDRecord VALUES ('2', 'The Worlds', 'Justin Bieber', 'Pop', 'Solo', '20.9', 'Out of stock', 'L2', 'Red')"
sqlInsertRow3.CommandText = _
"INSERT INTO CDRecord VALUES ('3', 'Pcd', 'Pussycat Dolls', 'Pop', 'Group', '25.9', 'Available', 'L3', 'Yellow')"
sqlInsertRow4.CommandText = _
"INSERT INTO CDRecord VALUES ('4', 'Element of freedom', 'Alicia Keys', 'Pop', 'Solo', '29.9', 'Available', 'L3', 'Brown')"



MessageBox.Show("Database has been initialised")[ / CODE]

what do you want in this you have created table. so do you want to retive or insert this data/ table in your database pleas tell us in brief.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.