|
|
|
date: Sun, 21 Sep 2008 23:57:10 -0700 (PDT),
group: microsoft.public.dotnet.framework.aspnet.webcontrols
back
Gridview won't update after inserting new record to MS Access
database using OLEDB
Hi,
Here is my code on a button click in the EmptyDataTemplate of a
Gridview. It saves the record to the database does not appear in the
gridview after the calling the databind method.
Any ideas ?
Below is my code
Protected Sub lnkSaveEmpty_Click(ByVal sender As Object, ByVal e
As System.EventArgs)
'save empty data
'retriev the description
Dim lnkSaveEmpty As LinkButton = sender
Dim row As GridViewRow =
DirectCast(lnkSaveEmpty.NamingContainer, GridViewRow)
Dim dpItemNo_Empty As DropDownList =
CType(row.FindControl("dpItemNo_Empty"), DropDownList)
Dim strSQL As String, cmd As OleDbCommand, dr As
OleDbDataReader
Dim objConnection As OleDbConnection
objConnection = New
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" &
Server.MapPath("~\app_data\print_manager.mdb"))
objConnection.Open() 'open the connection
'strSQL = "Update tbl_job_details SET job_id = " &
FormView1.DataKey(0) & ", card_id= " & dpItemNo_Empty.SelectedValue &
",qty=300 "
strSQL = "Insert INTO tbl_job_details (job_id,card_id,qty)
VALUES ( " & FormView1.DataKey(0) & "," & dpItemNo_Empty.SelectedValue
& ",300)"
cmd = New OleDbCommand(strSQL, objConnection)
cmd.ExecuteNonQuery()
GridView1.DataBind()
End Sub
Thanks
Geoff
date: Sun, 21 Sep 2008 23:57:10 -0700 (PDT)
author: unknown
Re: Gridview won't update after inserting new record to MS Access
database using OLEDB
On 22 Sep, 07:57, ggol...@gmail.com wrote:
> Hi,
>
> Here is my code on a button click in the EmptyDataTemplate of a
> Gridview. It saves the record to the database does not appear in the
> gridview after the calling the databind method.
>
> Any ideas ?
>
> Below is my code
>
> Protected Sub lnkSaveEmpty_Click(ByVal sender As Object, ByVal e
> As System.EventArgs)
> 'save empty data
> 'retriev the description
> Dim lnkSaveEmpty As LinkButton = sender
> Dim row As GridViewRow =
> DirectCast(lnkSaveEmpty.NamingContainer, GridViewRow)
> Dim dpItemNo_Empty As DropDownList =
> CType(row.FindControl("dpItemNo_Empty"), DropDownList)
>
> Dim strSQL As String, cmd As OleDbCommand, dr As
> OleDbDataReader
> Dim objConnection As OleDbConnection
> objConnection = New
> OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" &
> Server.MapPath("~\app_data\print_manager.mdb"))
> objConnection.Open() 'open the connection
> 'strSQL = "Update tbl_job_details SET job_id = " &
> FormView1.DataKey(0) & ", card_id= " & dpItemNo_Empty.SelectedValue &
> ",qty=300 "
> strSQL = "Insert INTO tbl_job_details (job_id,card_id,qty)
> VALUES ( " & FormView1.DataKey(0) & "," & dpItemNo_Empty.SelectedValue
> & ",300)"
> cmd = New OleDbCommand(strSQL, objConnection)
> cmd.ExecuteNonQuery()
> GridView1.DataBind()
>
> End Sub
>
> Thanks
>
> Geoff
Hi Geoff
Your code to save the record is obviously working OK but there is no
indication of how your GridView is linked to the Database table. Are
you using and AccessDataSource?
date: Mon, 22 Sep 2008 16:23:13 -0700 (PDT)
author: Stan
|
|