Hi Charlie,
From your description, I understood that you'd like to implement your ASP.NET application for two users'
communication with simple questions and answers. You have created the table with one NVARCHAR(256)
field but concerned about the maximum text length 256. Have I understood the issue correctly and
completely? If there is anything I misunderstood, please feel free to let me know.
As Anith has pointed it out, SQL Server supports 4000 characters for the NVARCHAR field. We can exceed
this 256 length up to maximum 4000 running the following Alter Table...Alter Column statement:
------------------------------------------------------------------------------------------------
Alter Table commDet Alter Column c_commtext nvarchar (4000)
------------------------------------------------------------------------------------------------
On the other hand, for better ways to store and retrieve binary large object - BLOB (Text, Image etc.), you
can try to use the StreamReader object and a string in ASP.NET to write BLOB data to a Text column in SQL
Server.
The following code also describes how to load BLOB data from a Text column in SQL Server database into
a Char array, and display it in the browser.
If you prefer a documented article, I believe the following Knowledge Base (KB) article is the best practices
to handle the BLOB data in ASP.NET:
326502 HOW TO: Read and Write BLOB Data by Using ADO.NET Through ASP.NET
http://support.microsoft.com/?id=326502 Code Sample below:
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Suppose the pub_info table contains a Text column called "pr_info" in Pubs database.
Sub Button3_Click demonstrates how to store data into a text column.
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim con As New SqlConnection("SERVER=.;UID=uid;PWD=pwd;DATABASE=Pubs")
Dim cmd As New SqlCommand("UPDATE pub_info SET pr_info=@txt WHERE
pub_id=0736 ", con)
Dim sr As StreamReader = New StreamReader(Server.MapPath("Test.txt"))
Dim s As String = sr.ReadToEnd
sr.Close()
Dim P As New SqlParameter("@txt", s)
cmd.Parameters.Add(P)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
cmd = Nothing
con = Nothing
Response.Write("Text saved to database")
End Sub
Sub Button4_Click retrieves data from a text column.
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
Dim con As New
SqlConnection("Server=yileiw2;uid=sqlauth;pwd=sqlauth;database=pubs")
Dim da As New SqlDataAdapter("Select * From pub_info", con)
Dim ds As New DataSet()
da.Fill(ds, "Pub_info")
Dim myRow As DataRow
myRow = ds.Tables("Pub_info").Rows(0)
Dim MyData() As Char
MyData = myRow("pr_info")
Response.Buffer = True
Response.ContentType = "text/plain"
Response.Write(MyData)
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Does that answer your question Charlie? Please apply my suggestions above and let me know if this helps
resolve your problem. If there is anything more I can do to assist you, please feel free to post it in the group.
Best regards,
Billy Yao
Microsoft Online Support
----------------------------------------------------
Get Secure! -
www.microsoft.com/security This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only. Thanks.