错误是'Sqlexception was unhanded ' There was an error parsing the query. [ Token line number = 1,Token line offset = 8,Token in error = * ]
Dim con As SqlCeConnection = New SqlCeConnection("Data Source = C:\Users\vineet\Documents\Visual Studio 2010\Projects\sqlProject\sqlProject\studentDB.sdf")
Dim dcmd As SqlCeCommand
Dim da As SqlCeDataAdapter
Dim ds As DataSet
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' ShowData()
End Sub
Public Sub ShowData()
dcmd = New SqlCeCommand("Select * FROM studentTable", con)
If con.State = ConnectionState.Closed Then con.Open()
'now we will populate the dataset with the help of data adapter
da = New SqlCeDataAdapter(dcmd)
ds = New DataSet()
da.Fill(ds, "MyTable")
DataGridStudents.DataSource = ds.Tables("MyTable").DefaultView
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
ShowData()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
dcmd = New SqlCeCommand("Delete * From studentTable Where name=@name", con)
dcmd.Parameters.AddWithValue("@name", TextBox6.Text)
If con.State = ConnectionState.Closed Then con.Open()
dcmd.ExecuteNonQuery()
ShowData()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
dcmd = New SqlCeCommand("Insert Into studentTable(ID,name,address,mobile,email) Values(@fID,@fname,@faddress,@fmobile,@femail)")
dcmd.Parameters.AddWithValue("@ID", TextBox1.Text)
dcmd.Parameters.AddWithValue("@fname", TextBox1.Text)
dcmd.Parameters.AddWithValue("@faddress", TextBox1.Text)
dcmd.Parameters.AddWithValue("@fmobile", TextBox1.Text)
dcmd.Parameters.AddWithValue("@femail", TextBox1.Text)
If con.State = ConnectionState.Closed Then con.Open()
dcmd.ExecuteNonQuery()
ShowData()
End Sub
End Class