Click here to Skip to main content
13,050,606 members (85,708 online)
Rate this:
 
Please Sign up or sign in to vote.
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:


 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 27-Dec-12 7:54am
SQLmis314
Updated 27-Dec-12 8:04am
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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

http://www.w3schools.com/sql/sql_insert.asp[^]
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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 :

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

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 27 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100