1loudsvt
Member
- Joined
- Mar 15, 2011
- Messages
- 8
- Programming Experience
- 3-5
using the code below when i click the update button the page reloads but the text box displays the original value and not the updated one. i get no errors at all. i tried removing the variable from the update statement and adding a hard coded value and it will then update the database to that hard coded value. really confused and frustrated. thanks for the help.
VB.NET:
Imports System.Data.OleDb
Partial Class CP
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim strSQL As String
strSQL = "SELECT * from FrontPage WHERE Headline = 'a'"
Dim conConnection As New OleDbConnection
conConnection.ConnectionString = "Provider=SQLOLEDB;Data Source=xxxxxx;Initial Catalog=xxxxxxx;User ID=xxxxxxxxx;Password=xxxxxxxx;"
conConnection.Open()
Dim cmdcommand As New OleDbCommand(strSQL, conConnection)
Dim rdrReader As OleDbDataReader
rdrReader = cmdcommand.ExecuteReader
If rdrReader.Read Then
txtFP.Text = rdrReader("body").ToString
End If
conConnection.Close()
cmdcommand.Dispose()
rdrReader.Close()
End Sub
Protected Sub btnUpdt_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpdt.Click
Dim strSQL As String
Dim strFP As String = txtFP.Text.ToString
strSQL = "UPDATE FrontPage SET body = 0000000000"
'" + strFP + "'"
Dim conConnection As New OleDbConnection
conConnection.ConnectionString = "Provider=SQLOLEDB;Data Source=xxxxx;Initial Catalog=xxxxxxx;User ID=xxxxxxxx;Password=xxxxxxxxx;"
conConnection.Open()
Dim cmdCommand As New OleDbCommand(strSQL, conConnection)
cmdCommand.ExecuteNonQuery()
conConnection.Close()
cmdCommand.Dispose()
End Sub
End Class