Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding fulltext articles into SQL Server 1

Status
Not open for further replies.

sonya9879

Programmer
Jun 18, 2004
147
CA
Hi,

I have this table:

TABLENAME: ARTICLES
ID INT
DATE DATETIME
ABSTRACT VARCHAR(50)
FULLARTICLE VARCHAR(2500)

and I want to store articles text in this table. the articles are a page long, about 2500 characters max and later I want to be able to search across each article in the table and I will be using Full-Text Indexing.

I am having problems adding the articles into the database. It probably has to do with the size of text I am sending. If I try to send one line of text it works fine, but when I try to send one page of text I get empty data in the fullarticle field.

This is the procedure I use:

Public Function InsertArticle(ByVal Abstract As String, ByVal fullarticle As string) As String
Dim myConnection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("myconnectionstring"))
Dim myCommand As SqlCommand = New SqlCommand("mystoredprocedure", myConnection)

myCommand.CommandType = CommandType.StoredProcedure

Dim parameterabstract As SqlParameter = New SqlParameter("@abstract", SqlDbType.varchar, 50)
parameterabstract.Value = abstract
myCommand.Parameters.Add(parameterabstract)

Dim parameterfullarticle As SqlParameter = New SqlParameter("@fullarticle", SqlDbType.varchar, 2500)
parameterfullarticle.Value = fullarticle
myCommand.Parameters.Add(parameterfullarticle)

' Open the connection and execute the Command
myConnection.Open()
Try
myCommand.ExecuteNonQuery()
Catch ex As Exception
response.write(ex.Message)
End Try
myConnection.Close()
End Function

Any help will be appreciated. I need to be able to retrieve the articles later and viewed in a web page that's why I was using varchar fields. Is it ok to use varchar or for the amount of text I am using should be using something else?
 
what error does it throw???

Known is handfull, Unknown is worldfull
 
no error, i just do not get the data inserted. I have a textarea and i paste the article (one page long) when I try to inserted I get the abstract but the fulltext appears blank. Now if I try to send one line of text, i see the one line of text.
 
hmm...

one more thing, the text that u r sending, does it have leading line feeds???

Known is handfull, Unknown is worldfull
 
it may have, the text is added in a textarea and it has character returns on paragraphs. I am taking the text as it is from the textarea, i.e. fullarticle.text and insert that into the table. Nothing crashes and the insert does occurred but as I said when there are long text I just get a blank entry in the fullarticle field.
 
how are u confirming that data is empty? by looking it up in SQL enterprise manager?

if the start of the text has line fed the field will look empty but will really have data (give focus to the field and press down key)...

Known is handfull, Unknown is worldfull
 
I look like stupid right now, but you are 100% right, I was looking at EM and it was blank but I just did a select statement to pullout the record to verify that was empty or not and I got all the text right on the screen.
I should have done that before instead of bothering people like yourself, thanks a lot vbkris.

btw, do you think that I am doing ok using the varchar field if I will be using 2500 chars aproximately?

thanks again
 
yes, its good upto 8000 characters...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top