Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Con As SqlCeConnection
Dim Adapter As SqlCeDataAdapter
Dim dtuser As New DataTable
Con = New SqlCeConnection("Data Source =" _
+ (System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.GetName.CodeBase) + "\AppDatabase2.sdf;"))
Con.Open()
Dim sql As SqlCeCommand = Con.CreateCommand()
sql.CommandText = (" SELECT color.[colornam] AS colorname " & _
" FROM [car] LEFT JOIN " & _
" color ON car.[colorcde] = color.[colorcde];")
sql.CommandType = CommandType.Text
Adapter = New SqlCeDataAdapter(sql)
Adapter.Fill(dtuser)
txtUser.Text = dtuser.Rows(0)("colorname").ToString
Con.Close()
End Sub