Re: Problem reading column of type 'text' from Sql server
- From: "Aamir Mahmood" <a@xxx>
- Date: Wed, 5 Oct 2005 16:07:33 +0500
Ok guys,
I have solved the problem. I don't know it was the actual reason or not but
it solved.
I was reading the two text columns in order different than the columns in
the tables. Now I am reading the those 'text' columns in the same order
they are designed in the table.
The order matters only for 'text' type columns in this particular case. The
rest of the columns (varchar, int etc) can be read in any order, it does not
effect the output.
Thanks,
-
AM
"Raj Kasi [MSFT]" <lkasi@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:e8Y7pZUyFHA.3408@xxxxxxxxxxxxxxxxxxxxxxx
>I have inserted text values larger than 30-60K as you mentioned and read
>them back correctly without any problems using VB6, MDAC 2.8, SQL Server
>2000 SP4 and Win XP SP2. The sample code is not much different from what I
>mentioned below except that this time you use a loop to generate the text
>value of appropriate size.
>
> -------------------------------------------------------------
> This posting is provided "AS IS", with no
> warranties, and confers no rights.Please
> do not send email directly to this alias.
> This alias is for newsgroup purposes only
> -------------------------------------------------------------
>
> "Aamir Mahmood" <a@xxx> wrote in message
> news:ekWjJ0NyFHA.2516@xxxxxxxxxxxxxxxxxxxxxxx
>> My text values are well larger than 8K in size (fall between 30-60K).
>> May
>> be this is the problem. And my example with that large text still reads
>> empty strings.
>>
>> I have VB6 (SP6) and MDAC 2.8, SQL Server 2000 (SP4), Win XP Pro (SP2)
>>
>> Has someone ever got into this situation. I didn't know that using text
>> type would get me in this problem. But I can't use any other type.
>>
>> A working example will be appreciated.
>>
>> Thanks
>> -
>>
>> AM
>>
>> "Raj Kasi [MSFT]" <lkasi@xxxxxxxxxxxxxxxxxxxx> wrote in message
>> news:OUaBOAIyFHA.1252@xxxxxxxxxxxxxxxxxxxxxxx
>>>I will provide a simple example below. The text values are being read
>>>correctly without any issues.Replace the username, password, catalog,
>>>data source with appropriate values. As you can see below I am fetching
>>>the data into the recordset and reading the text column(s) values as you
>>>mentioned below. Also I am displaying them when the recordset is
>>>traversed.
>>>
>>> ==============================================================================
>>> Dim cn As New ADODB.Connection
>>> Dim txt As String
>>>
>>> cn.Open "Provider=SQLOLEDB;User
>>> ID=<username>;password=<password>;Initial Catalog=<catalog name>;Data
>>> Source=<data source name>"
>>>
>>> cn.Execute "create table temp_test(colint1 int, coltext2 text, colchar3
>>> char, coltext4 text, colint5 int)"
>>>
>>> cn.Execute "insert into temp_test values(1,'2. Testing text column
>>> 1234567890 abcdefghijkldhjdjhasdhfsdjhdf','a','4. Testing text column
>>> 1234567890 abcdefghijkljhajhdfsjhdf',5)"
>>>
>>> rs.Open "select * from temp_test", cn
>>>
>>> txt = rs.Fields("coltext2").Value
>>>
>>> MsgBox txt
>>>
>>> txt = rs.Fields("coltext4").Value
>>>
>>> MsgBox txt
>>>
>>> While Not rs.EOF
>>> For j = 0 To rs.Fields.Count - 1
>>> txt = rs.Fields.Item(j).Value
>>> MsgBox txt
>>> Next j
>>> rs.MoveNext
>>> Wend
>>>
>>> cn.Execute "drop table temp_test"
>>>
>>> cn.Close
>>> ==============================================================================
>>>
>>> -------------------------------------------------------------
>>> This posting is provided "AS IS", with no
>>> warranties, and confers no rights.Please
>>> do not send email directly to this alias.
>>> This alias is for newsgroup purposes only
>>> -------------------------------------------------------------
>>>
>>>
>>> "Aamir Mahmood" <a@xxx> wrote in message
>>> news:OYVHJCFyFHA.2848@xxxxxxxxxxxxxxxxxxxxxxx
>>>> Hi all,
>>>>
>>>> My code is like following
>>>>
>>>> dim rs as new adodb.Recordset
>>>> rs.open "select * from articles", myConn
>>>>
>>>> The problem is two of the columns in the table "Articles" are of type
>>>> 'text'
>>>> in sql server.
>>>> When I try to read them like
>>>> dim txt as string
>>>> txt = rs.Fields("ArticleText").Value
>>>>
>>>> It always reads a blank string?? Same is for the other column of
>>>> 'text'
>>>> type.
>>>>
>>>> What I am doing wrong? Please help me.
>>>>
>>>> -
>>>> Amir Mahmood
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
.
- Follow-Ups:
- Re: Problem reading column of type
- From: jmiglietta@xxxxxxxxxx
- Re: Problem reading column of type
- References:
- Problem reading column of type 'text' from Sql server
- From: Aamir Mahmood
- Re: Problem reading column of type 'text' from Sql server
- From: Raj Kasi [MSFT]
- Re: Problem reading column of type 'text' from Sql server
- From: Aamir Mahmood
- Re: Problem reading column of type 'text' from Sql server
- From: Raj Kasi [MSFT]
- Problem reading column of type 'text' from Sql server
- Prev by Date: Re: Problem reading column of type 'text' from Sql server
- Next by Date: Re: simple data form
- Previous by thread: Re: Problem reading column of type 'text' from Sql server
- Next by thread: Re: Problem reading column of type
- Index(es):
Relevant Pages
|