what i want the code to do is to take input from a text box ID number then it takes the record which the ID belongs to and insert it in another table but I changed the SQL Statement and still when I press the button nothing happens
Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; data source= " & Server.MapPath("~/Members.mdb"))
Dim cmd As New OleDbCommand
Dim i As Integer
cmd.Connection = con
cmd.CommandType = Data.CommandType.Text
cmd.CommandText = "insert into kfupm_stu_visitor (kfupm_stu_id, stu_name, kfupm_maj_id, kfupm_dep_id, level_id) select * from kfupm_stu where fupm_stu_id like @kfupm_stu_id"
cmd.Parameters.Add("KFUPM_STU_ID", OleDbType.Integer).Value = "%" & txtSTU_ID.Text & "%"
con.Open()
Try
i = cmd.ExecuteNonQuery()
Catch ex As Exception
Response.Redirect("msgpage.aspx?id=1")
Finally
con.Close()
End Try
Response.Redirect("msgpage.aspx?id=2")
End Sub
If you’re using a query to fill the columns, there’s no need for the
values (...)portion. It should just be:Of course, that assumes that the columns in
kfupm_stumatch exactly the columns in theinsert intolist.