Click here to Skip to main content
15,892,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a batten button to search in a table from Db by reading from text box Id number then displaying the result in a grid this is the code:


VB
Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
       Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; data source= " & Server.MapPath("~/Members.mdb"))
       Dim cmd As New OleDbCommand
       Dim rd As OleDbDataReader
       lblerror.Text = ""
       cmd.Connection = con
       cmd.CommandType = Data.CommandType.Text
       cmd.CommandText = "select * from KMM_STU where KMM_STU_ID like @KMM_STU_ID"
       cmd.Parameters.Add("KMM_STU_ID", OleDbType.VarChar).Value = "%" & txtSTU_ID.Text & "%"
       con.Open()
       rd = cmd.ExecuteReader

       If rd.HasRows() Then
           GridView1.DataSource = rd
           GridView1.DataBind()
           rd.Close()
           con.Close()
       Else
           lblerror.text = "No Records were Found"
       End If



and now I added another batten button to save the information from the same record that have been generated into a new table where the ID = the id in the text box but i don't know how?


[edit]Typo fixed for clarity only "batten" for "button" - OriginalGriff[/edit]
Posted
Updated 27-Dec-12 8:04am
v2

Run an insert query for the new record and insert it into your new table,

http://www.w3schools.com/sql/sql_insert.asp[^]
 
Share this answer
 
1. Make a datasource connected with database that you are using , then select that table,
2.For data bind grid-view you can use the following :

VB
Datasource1.Selectcommand="select * from KMM_STU where KMM_STU_ID like "%" & txtSTU_ID.Text & "%"
Datasource1.Databind()
Gridview1.databind()
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900