ASP - Read Long Column data from sql in ASP - Asked By Lalitha Kumaran on 16-Jun-08 02:52 AM

I have created one table in which contains Document column with Long data type.i have copied the data  with 60 lines and done insertion also.now, how do i read data from that table in asp or asp.net?..


try this... - Vasanthakumar D replied to Lalitha Kumaran on 16-Jun-08 03:06 AM

hi,

here is C# the code to retrive the data from the table and show it in asp.net  Text control looks like label control

Dataset ds = new Dataset();

//fill your  dataset wiht the requried details

txtDetails.Text = ds.Tables[0].Rows[0]["Column Name"].ToString();

and in desing  time set the text box as below

<asp:TextBox runat="server" ID="txtDet" TextMode="MultiLine" Wrap="true" Width="150px" ReadOnly = "true"

BorderStyle="none" BorderWidth="0" Rows="5" ></asp:TextBox>

the above will show your data in textbox, but it looks like label control.

Try this code - Sagar P replied to Lalitha Kumaran on 16-Jun-08 03:19 AM

Dim cn As New SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings.Item("DataBaseConnection").ConnectionString)

cn.Open()

Dim Query As String = "Select field1 from UrTable where cond"

Dim Adpt As New SqlClient.SqlDataAdapter(Query, cn)

Dim ds As New DataSet

Adpt.Fill(ds)

Dim str As String

str = ds.Tables(0).Rows(0).Item(0).ToString

Then you can use this str further in your code.

Go like this. This will solve your problem.

If your data for that column is more then you can use BLOB datatype also.

Best Luck!!!!!!!!!!!!!!!!
Sujit.

Try this code - Sagar P replied to Lalitha Kumaran on 16-Jun-08 03:17 AM

Dim cn As New SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings.Item("DataBaseConnection").ConnectionString)

cn.Open()

Dim Query As String = "Select field1 from UrTable where cond"

Dim Adpt As New SqlClient.SqlDataAdapter(Query, cn)

Dim ds As New DataSet

Adpt.Fill(ds)

Dim str As String

str = ds.Tables(0).Rows(0).Item(0).ToString

Then you can use this str further in your code.

Go like this. This will solve your problem.

Best Luck!!!!!!!!!!!!!!!!
Sujit.

Try this code - Sagar P replied to Lalitha Kumaran on 16-Jun-08 03:17 AM

Dim cn As New SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings.Item("DataBaseConnection").ConnectionString)

cn.Open()

Dim Query As String = "Select field1 from UrTable where cond"

Dim Adpt As New SqlClient.SqlDataAdapter(Query, cn)

Dim ds As New DataSet

Adpt.Fill(ds)

Dim str As String

str = ds.Tables(0).Rows(0).Item(0).ToString

Then you can use this str further in your code.

Go like this. This will solve your problem.

Best Luck!!!!!!!!!!!!!!!!
Sujit.

using datareader u can access it by GetDouble method - Deepak Ghule replied to Sagar P on 16-Jun-08 03:29 AM

 

refer it....

 

Dim command As SqlCommand = New SqlCommand( _
          "SELECT * FROM Employees", connection)
        connection.Open()

        Dim reader As SqlDataReader = command.ExecuteReader()

        Do While reader.HasRows
            Console.WriteLine(vbTab & reader.GetName(0) _
              & vbTab & reader.GetName(1))

            Do While reader.Read()
                Console.WriteLine(vbTab & reader.GetInt32(0) _
                  & vbTab & reader.GetString(1)_

                  & vbTab & reader.GetDouble(2))
            Loop

            reader.NextResult()
        Loop

Thanks for quick response - Lalitha Kumaran replied to Vasanthakumar D on 16-Jun-08 03:32 AM

Thanks for your response. But i am going to use long data in asp and asp.net.how i do it in ASP


Read Long Column data from sql in ASP - Swapnil Salunke replied to Lalitha Kumaran on 16-Jun-08 03:38 AM

Hello Lalitha Kumaran

Fillout the dataset using dataadapter .
then take one string object and assign the desired value to the string Now You can use this with any of your controllike textbox etc. But textbox should be multiline

dataset ds=new dataset();
// Data filling Operations comes here
string str= ds.Tables[0].Rows[0]["Column Name"].ToString();
// assign this string to any cntrl you want.
Dataset Filling Logic
 

Dim cn As New SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings.Item("DataBaseConnection").ConnectionString)

cn.Open()

Dim Query As String = "Select Document from UrTable where cond"

Dim sqlda As New SqlClient.SqlDataAdapter(Query, cn)

Dim ds As New DataSet

sqlda.Fill(ds);

Happy Coding takecare


 


 


use Text Area field for ASP - Vasanthakumar D replied to Lalitha Kumaran on 16-Jun-08 04:26 AM

Hi,

I am not much familiar with ASP. After you have get the data from database just bind it with the Text area control...

below is the format for the text area control...

<textarea rows="5" readonly="readonly" id="txtData" style="width:150px;" cols="50"></textarea>

check this is ASP - Santhosh N replied to Lalitha Kumaran on 16-Jun-08 04:30 AM

You can read directly into any variable in ASP...

check here how to conenct to database from ASP and read data from table...

http://www.haneng.com/Lessons_17.asp

http://www.4guysfromrolla.com/webtech/042599-1.shtml

check this.. - Santhosh N replied to Lalitha Kumaran on 16-Jun-08 04:37 AM

Check this article which explains how to read clob types in .net

You can use GetOracleLob method of  OracleDataReader class obejct...

http://www.codeproject.com/KB/database/C__and_Oracle.aspx

Reply - alice johnson replied to Lalitha Kumaran on 17-Jun-08 10:25 PM

After the fill method, write this part of the code:

dataset ds=new dataset();
// Data filling Operations comes here
string str= ds.Tables[0].Rows[0]["Column Name"].ToString();
// assign this string to any cntrl you want.
Dataset Filling Logic
 

Dim cn As New SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings.Item("DataBaseConnection").ConnectionString)

cn.Open()

Dim Query As String = "Select Document from Tablename where cond"

Dim sqlda As New SqlClient.SqlDataAdapter(Query, cn)

Dim ds As New DataSet

sqlda.Fill(ds);