Hi,
I'm very new to web programming and am trying to insert/update records to an access db via a webform. Use the form from 'HowToBuildAWebDataEntryApp' .NET Framework example as a guide in building my WebForm, except using Access 2000. When I do a 'Build & Browse' everything seems to go OK - in other words, No Errors generated, just the DB is never updated?? Following is some of my code:
Protected Const MSDE_CONNECTION_STRING As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\File Databases\WebKB.mdb"
Private Sub SaveNode()
Dim strSQL As String
If btnSaveNode.CommandArgument = "Add" Then
strSQL = _
"INSERT INTO Nodes (NodeID,Title) " & _
"VALUES (@NodeID,@Title)"
Else
strSQL = _
"UPDATE Nodes " & _
"SET Title = @Title, " & _
" NodeID = @NodeID " & _
"WHERE KeyID = @KeyID"
End If
Dim scnnNodes As New OleDbConnection(MSDE_CONNECTION_STRING)
Dim scmd As New OleDbCommand(strSQL, scnnNodes)
' Add all the required SQL parameters.
With scmd.Parameters
If btnSaveNode.CommandArgument <> "Add" Then
.Add(New OleDbParameter("@KeyID", _
OleDbType.Integer)).Value = _
CInt(grdNodes.DataKeys(grdNodes.SelectedIndex).ToString)
End If
.Add(New OleDbParameter("@Title", _
OleDbType.VarChar, 50)).Value = txtTitle.Text
.Add(New OleDbParameter("@NodeID", _
OleDbType.Integer)).Value = CInt(txtNodeID.Text)
End With
Try
scnnNodes.Open()
scmd.ExecuteNonQuery()
Cache.Remove("dvNodes"
BindNodesGrid()
strMsg = "Main Node successfully saved to the database."
pnlNode.Visible = False
txtNodeID.Visible = False
txtTitle.Visible = False
btnSaveNode.Visible = False
Catch exp As Exception
strErrorMsg = "Database error! Main Node not saved to the " & _
"database. Error message: " & exp.Message
Finally
scnnNodes.Close()
End Try
End Sub
Like I said, I'm brand new to Web programming - mostly work in FoxPro. Any help greatly appreciated. Can't seem to get around this problem.
TIA,
Dave Whitt
I'm very new to web programming and am trying to insert/update records to an access db via a webform. Use the form from 'HowToBuildAWebDataEntryApp' .NET Framework example as a guide in building my WebForm, except using Access 2000. When I do a 'Build & Browse' everything seems to go OK - in other words, No Errors generated, just the DB is never updated?? Following is some of my code:
Protected Const MSDE_CONNECTION_STRING As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\File Databases\WebKB.mdb"
Private Sub SaveNode()
Dim strSQL As String
If btnSaveNode.CommandArgument = "Add" Then
strSQL = _
"INSERT INTO Nodes (NodeID,Title) " & _
"VALUES (@NodeID,@Title)"
Else
strSQL = _
"UPDATE Nodes " & _
"SET Title = @Title, " & _
" NodeID = @NodeID " & _
"WHERE KeyID = @KeyID"
End If
Dim scnnNodes As New OleDbConnection(MSDE_CONNECTION_STRING)
Dim scmd As New OleDbCommand(strSQL, scnnNodes)
' Add all the required SQL parameters.
With scmd.Parameters
If btnSaveNode.CommandArgument <> "Add" Then
.Add(New OleDbParameter("@KeyID", _
OleDbType.Integer)).Value = _
CInt(grdNodes.DataKeys(grdNodes.SelectedIndex).ToString)
End If
.Add(New OleDbParameter("@Title", _
OleDbType.VarChar, 50)).Value = txtTitle.Text
.Add(New OleDbParameter("@NodeID", _
OleDbType.Integer)).Value = CInt(txtNodeID.Text)
End With
Try
scnnNodes.Open()
scmd.ExecuteNonQuery()
Cache.Remove("dvNodes"
BindNodesGrid()
strMsg = "Main Node successfully saved to the database."
pnlNode.Visible = False
txtNodeID.Visible = False
txtTitle.Visible = False
btnSaveNode.Visible = False
Catch exp As Exception
strErrorMsg = "Database error! Main Node not saved to the " & _
"database. Error message: " & exp.Message
Finally
scnnNodes.Close()
End Try
End Sub
Like I said, I'm brand new to Web programming - mostly work in FoxPro. Any help greatly appreciated. Can't seem to get around this problem.
TIA,
Dave Whitt