D
David
I am using subroutine to add a record to a table that is bound to a GridView
via DataSourceID (SQL table). I have a link button to do this as I
sometimes need to do special processing. After the record is inserted, the
new record does not immediately show on the GridView and I'm not sure why.
Below is my code if anyone can help. Thanks.
Protected Sub BtnNewSubfile_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles BtnNewSubfile.Click
'Inserts a new blank Subfiles record for current file number
Dim conFileData As OleDbConnection
Dim strSQL As String
conFileData = New
OleDbConnection(ConfigurationManager.ConnectionStrings("FiledataOledb").ConnectionString)
conFileData.Open()
strSQL = "INSERT INTO dbo.Subfiles ([SeqNo], [FileNumber])" & _
" SELECT TOP 1 MAX([SeqNo])+1, [FileNumber] FROM dbo.Subfiles WHERE
[FileNumber]=" & txtFileNumber.Text & " GROUP BY [FileNumber]"
Dim cmdInsert As OleDbCommand
cmdInsert = New OleDbCommand(strSQL, conFileData)
cmdInsert.ExecuteNonQuery()
SqlDataSource2.DataBind()
conFileData.Close()
End Sub
via DataSourceID (SQL table). I have a link button to do this as I
sometimes need to do special processing. After the record is inserted, the
new record does not immediately show on the GridView and I'm not sure why.
Below is my code if anyone can help. Thanks.
Protected Sub BtnNewSubfile_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles BtnNewSubfile.Click
'Inserts a new blank Subfiles record for current file number
Dim conFileData As OleDbConnection
Dim strSQL As String
conFileData = New
OleDbConnection(ConfigurationManager.ConnectionStrings("FiledataOledb").ConnectionString)
conFileData.Open()
strSQL = "INSERT INTO dbo.Subfiles ([SeqNo], [FileNumber])" & _
" SELECT TOP 1 MAX([SeqNo])+1, [FileNumber] FROM dbo.Subfiles WHERE
[FileNumber]=" & txtFileNumber.Text & " GROUP BY [FileNumber]"
Dim cmdInsert As OleDbCommand
cmdInsert = New OleDbCommand(strSQL, conFileData)
cmdInsert.ExecuteNonQuery()
SqlDataSource2.DataBind()
conFileData.Close()
End Sub