挿入データをテーブルに保存するために、小さなアプリケーションを実行しました....
アプリケーションを閉じた後、アプリケーションはデータを保存していません..
コードのどこが間違っているのか教えてください。
Imports System.Data
Imports System.Data.SqlServerCe
Public Class Form1
Public connstring As New String("Data Source=|DataDirectory|\test_db.sdf")
Public sqlconn As New SqlCeConnection(connstring)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim name As New String("jaifar")
Dim myCommand As New SqlCeCommand("Insert Into table1 (id) Values('" + name + "')", sqlconn)
If sqlconn.State = Data.ConnectionState.Closed Then sqlconn.Open()
myCommand.ExecuteNonQuery()
Me.Table1TableAdapter.Fill(Me.Test_dbDataSet1.table1)
End Sub
Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
sqlconn.Close()
sqlconn = Nothing
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'Test_dbDataSet1.table1' table. You can move, or remove it, as needed.
Me.Table1TableAdapter.Fill(Me.Test_dbDataSet1.table1)
End Sub
End Class