Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Inserting & Fetching Data into a column of TEXT Data type in SQL server 2000 Using ASP.NET

Reply
Thread Tools

Inserting & Fetching Data into a column of TEXT Data type in SQL server 2000 Using ASP.NET

 
 
Bhavesh
Guest
Posts: n/a
 
      07-16-2007
Hello genious people,

I m trying to insert a LARGE text from Multiline Textbox into my table
of sqlserver2000. I m using vs-2005.

Please note that I dont want to store blob data From FILE TO TABLE,
like storing IMAGE into DB.

I hav searched lots of articles on that but didn't get success.

I hav tried following code from somewhere i found.
But I m getting Error that

"Failed to convert parameter value from a Byte[] to a String." (This
Error is displayed by smart tag of VS-2005) And then when I press F5 ,
my IE shows following Error.

/
************************************************** ************************************************** *****
Object must implement IConvertible.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Object must implement
IConvertible.

Source Error:
Line 102: Try
Line 103: myConnection.Open()
Line 104: myCommand.ExecuteNonQuery() <---- Here Line is
highlighted by IE
Line 105: myConnection.Close()
Line 106: Response.Write("New TestText successfully
added!")

************************************************** ************************************************** *****/

Please tell me wht is wrong with my following code. & if any wrong
then pls.

Also pls tell me how to fetch all that data once at a time. Or
required ro use loop like . But dont know syntax. pls help me its
urgent for me.

Public Sub StoreTextInDB()
Dim intTextSize As Int64
'''''''Dim TextStream As Stream

'''''' Gets the Size of the Text
intTextSize = Len(Trim(txtDesc.Text))
Dim TextContent(intTextSize) As Byte
'************************************************* ********
' '''''Reads the Image
TextContent =
System.Text.Encoding.Unicode.GetBytes(Trim(txtDesc .Text))
'' ''TextStream = Request.InputStream
'' ''Dim intStatus As Integer
'' ''intStatus = TextStream.Read(TextContent, 0, intTextSize)
'' ''************************************************ *********
'' '' Create Instance of Connection and Command Object
Dim szCon As String
szCon = "Data Source=192.168.151.109;uid=sa;pwd=sa;Initial
Catalog=www_charm_co_uk_latest"
Dim myConnection As New SqlConnection(szCon)
Dim myCommand As New
SqlCommand("DEMO_For_InsertTEXT_Datatype", myConnection)

'''' Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure

Dim prmStudNo As New SqlParameter("@StudNo", SqlDbType.Int, 4)
prmStudNo.Value = 1
myCommand.Parameters.Add(prmStudNo)

'''''''' Add Parameters to SPROC
Dim prmTestText As New SqlParameter("@TestText",
SqlDbType.Text, 16)
prmTestText.Value = TextContent
myCommand.Parameters.Add(prmTestText)

Try
myConnection.Open()
myCommand.ExecuteNonQuery()
myConnection.Close()
Response.Write("New TestText successfully added!")
Catch SQLexc As SqlException
Response.Write("Insert Failed. Error Details are: " &
SQLexc.ToString())
End Try
End Sub

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fetching & Inserting Data into a column of TEXT Data type in SQL server 2000 Using ASP.NET Bhavesh ASP .Net 5 07-18-2007 07:39 AM
Fetching & Inserting Data into a column of TEXT Data type in SQL server 2000 Using ASP.NET Bhavesh ASP .Net 1 07-17-2007 09:05 AM
Creating a page for inserting new records into a SQL Server 2000 DB newt039@gmail.com ASP .Net 0 01-26-2007 09:33 PM
Problem (Inserting records into sql server 2000 using asp.net) =?Utf-8?B?UCBvZiBEaHVtcA==?= ASP .Net 2 08-18-2005 03:29 PM
Inserting into sql server using parameterized - get new column value ryan.mclean@gmail.com ASP .Net 10 05-25-2005 02:03 PM



Advertisments