S
Showjumper
I am working on content management system that allows the text in articles
to be updated. On the main page of the cms (default.aspx) the article titles
are shown with an edit hyperlink that sends the user to the edit page which
has a textbox and an update linkbutton. All of my data access logic is a
separate class file and i then call the appropriate routine. However the
text in the textbox doesnt update. It only updates when a text value is
hardcoded into the the sql statement. Maybe one of you can figure out what
the heck is going on. Thanks in advance...Here is the code:
'this sub populates the textbox
Public Sub ShowArticleText(ByVal ArticleID As String, ByRef ArticleText As
String)
Dim cmd As New OleDbCommand("Select * From Articles Where ArticleID =
@ArticleID", RDConn)
cmd.Parameters.Add(New OleDbParameter("@ArticleID", cmd))
cmd.Parameters("@ArticleID").Value = ArticleID
da.SelectCommand = cmd
da.Fill(ds, "Articles")
ArticleText = ds.Tables(0).Rows(0).Item("ArticleText").ToString
End Sub
' this is the sub to update the text in the texbox
Public Function UpdateComment(ByVal ArticleText As String, ByVal articleid
As String) As OleDbCommand
Dim cmd As New OleDbCommand("UPDATE Articles SET ArticleText = @ArticleText
WHERE ArticleID =@ArticleID", RDConn)
cmd.Parameters.Add("@ArticleText", cmd).Value = ArticleText
cmd.Parameters.Add("@ArticleID", cmd).Value = articleid
da.UpdateCommand = cmd
da.Fill(ds, "Articles")
End Function
And in the page w/ the textbox
Dim Dal As New DataLayer.AccessDataLayer
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dal.ShowArticleText(Request.QueryString("ArticleID"), TextBox1.Text)
End Sub
Sub BindData()
Dal.ShowArticleText(Request.QueryString("ArticleID"), TextBox1.Text)
End Sub
Private Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles LinkButton1.Click
If IsValid Then
Dal.UpdateComment(TextBox1.Text, Request.QueryString("articleid"))
End If
BindData()
End Sub
to be updated. On the main page of the cms (default.aspx) the article titles
are shown with an edit hyperlink that sends the user to the edit page which
has a textbox and an update linkbutton. All of my data access logic is a
separate class file and i then call the appropriate routine. However the
text in the textbox doesnt update. It only updates when a text value is
hardcoded into the the sql statement. Maybe one of you can figure out what
the heck is going on. Thanks in advance...Here is the code:
'this sub populates the textbox
Public Sub ShowArticleText(ByVal ArticleID As String, ByRef ArticleText As
String)
Dim cmd As New OleDbCommand("Select * From Articles Where ArticleID =
@ArticleID", RDConn)
cmd.Parameters.Add(New OleDbParameter("@ArticleID", cmd))
cmd.Parameters("@ArticleID").Value = ArticleID
da.SelectCommand = cmd
da.Fill(ds, "Articles")
ArticleText = ds.Tables(0).Rows(0).Item("ArticleText").ToString
End Sub
' this is the sub to update the text in the texbox
Public Function UpdateComment(ByVal ArticleText As String, ByVal articleid
As String) As OleDbCommand
Dim cmd As New OleDbCommand("UPDATE Articles SET ArticleText = @ArticleText
WHERE ArticleID =@ArticleID", RDConn)
cmd.Parameters.Add("@ArticleText", cmd).Value = ArticleText
cmd.Parameters.Add("@ArticleID", cmd).Value = articleid
da.UpdateCommand = cmd
da.Fill(ds, "Articles")
End Function
And in the page w/ the textbox
Dim Dal As New DataLayer.AccessDataLayer
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dal.ShowArticleText(Request.QueryString("ArticleID"), TextBox1.Text)
End Sub
Sub BindData()
Dal.ShowArticleText(Request.QueryString("ArticleID"), TextBox1.Text)
End Sub
Private Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles LinkButton1.Click
If IsValid Then
Dal.UpdateComment(TextBox1.Text, Request.QueryString("articleid"))
End If
BindData()
End Sub