Stuffing repeated entries into the same field isn't really the best use of a
relational database. You'd be better off creating a child comment table
that held each entry. I'd also break out the date and user ID into their
own columns, so you could do searches and joins. Much easier to work with
and use later on. Your current design gets you a blob of data that is useful
only for display.
However if you really want to do it, you can concatenate in your UPDATE
statement.
.CommandText = "UPDATE ATTTblAttendance" & _
" SET Comments = COALESCE(Comments, '') +
Comments & _
" WHERE (UserID =
UserID) AND (Today = '"
& lblDate.Text & "') "
On 10/24/07, gail15322 < GCG%40miamidade.gov">GCG
miamidade.gov> wrote:
>
> I have a textbox and the user wants to append each data entry to the
> previous data entry such that at the end of the day the db field will
> have, 8:00 am UserID Breakfast 12:00 PM UserID Lunch 5:00 PM
> UserID Dinner. With each time period being entered at separate
> times of the day. Currently my code over writes the previous data
> entry.
>
> This is code:
> The portion of the code requires IIS Windows Authentication to be set
> Dim authUserName As String
> Dim userNamedbInsert As String
>
> authUserName = Request.ServerVariables("AUTH_USER")
> Session("userNamedbInsert") = authUserName
>
> If authUserName <> "" Then
> userNamedbInsert = Replace
> (authUserName, "newDomain", "")
> Else
> userNamedbInsert = Replace
> (authUserName, "oldDomain", "")
> End If
>
> 'Declare DateTime variables, for date and parsed date,
> i.e. Today
>
> Dim bDate As DateTime
> bDate = lblDate.Text
>
> Dim newCookie As HttpCookie = New HttpCookie
> ("SupervisorComment")
> newCookie.Values.Add("Comments", bDate & UCase
> (userNamedbInsert) & txtComment.Text)
> newCookie.Expires = #12/31/2010#
> Response.Cookies.Add(newCookie)
>
>
> 'Instantiate the command object
> Using cmdCommentUpdate As New
> System.Data.SqlClient.SqlCommand
>
> 'Establish connection to the database connection
> Dim sqlcon As New SqlClient.SqlConnection
> (ConfigurationManager.ConnectionStrings
> ("AttendanceConnectionString").ToString)
>
> 'Open connection
> sqlcon.Open()
>
> 'Pass opened connection (see above) to the command
> object
> cmdCommentUpdate.Connection = sqlcon
>
> 'Using "With/End With" pass content to columns from
> text objects and datatime variables (see above)
> With cmdCommentUpdate
> .Parameters.Add(New SqlClient.SqlParameter
> ("
Comments", bDate & UCase(userNamedbInsert)
> & txtComment.Text))
>
> 'Establish the type of commandy object
> .CommandType = CommandType.Text
>
> 'Pass the Update nonquery statement to the
> commandText object previously instantiated
> .CommandText = "UPDATE ATTTblAttendance" & _
> " SET Comments =
Comments & _
> " WHERE (UserID =
UserID) AND (Today = '"
> & lblDate.Text & "') "
>
> End With
>
> 'Execute the nonquerry via the command object
> cmdCommentUpdate.ExecuteNonQuery()
>
> 'Close the sql connection
> sqlcon.Close()
> Response.Redirect("~/Maintenance.aspx")
> End Using
>
> Thank you for your help.
>
> Gail
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
--
Dean Fiala
Very Practical Software, Inc
Now with Blogging...
http://www.vpsw.com/blogbaby
Microsoft MVP
[Non-text portions of this message have been removed]
.