Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Retreiving a Text field
Message
From
14/07/2009 14:05:34
 
General information
Forum:
ASP.NET
Category:
ADO.NET
Environment versions
Environment:
ASP.NET
Database:
MS SQL Server
Miscellaneous
Thread ID:
01412265
Message ID:
01412284
Views:
41
>>>>Hi all,
>>>>
>>>>I am trying to reteive and text from a Text data type field using Ado.net (and vb.Net). But all I seem to be getting is an integer value. Is there a special trick to retreiving it? And once I get it, and edit it, how would send it back to the server to save?
>>>
>>>Can you post some code?
>>>
>>>Also, may be it's better to switch to varchar(max) instead of Text?
>>
>>As for changing the data type, the database is a pre-existing database and another application owns it. I am developing a Query By Example application where only the Comment (Text) field can be modified.
>>
>>Here a snipit of code I am using to retreive the data.
>>
>>lcCmd = "select * from " & lcTable & " where Number='" & lcNumber & "'"
>>Dim cm As SqlCommand = New SqlCommand()
>>cm.CommandText = lcCmd
>>cm.Connection = cn
>>dr = cm.ExecuteReader
>>dr.Read()
>>
>>lcData = dr.Item("Comment").ToString()
>>
>>
>
>I see.
>
>1. Change lcNumber to be a parameter - to avoid SQL injection attacks.
>
>2. Try to list all the fields explicitly.
>
>3. The code dr.Read() should be changed to
>
>while dr.Read()
> lcData = dr("Comment").ToString()

Thanks for the suggestion. But I discovered the problem actual never existed. The text field actual did have numbers in them and the dataset was being read correctly. I guess should have look at the data before assuming i was getting the wrong data.
Greg Reichert
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform