Inserting BLOB Type column data with other columns data(normal Text) - SQL Statement

In below code, SQL Statement is used to Insert BLOB Type data using Serialization. It is required to insert other (normal text) with BLOB Type data as well. Like to get below SQL statement amended so that all the columns(ID,name, blob) can be inserted.

Just now below code working fine Inserting BLOB Type data.

I think it is not stright forward way to insert all the columns(normal text) with BLOB?


1    protected void button2_Click(object sender, EventArgs e)
2    	{
3    		//Connection string
4    		string oradb = datasource= mysource;userid="xyz" password="password"
6    		//Connection 
7    		OracleConnection conn = new OracleConnection(oradb);
8    		//Open connection
9    		conn.Open();
11   		// Start a transaction
12   		OracleTransaction txn = conn.BeginTransaction();
14   		//create Command object 
15   		OracleCommand cmd = new OracleCommand();
16   		cmd.Connection = conn;
18   		// Lock the result set using the "FOR UPDATE" clause
20   		//ToDo -- update to insert other column values as well
21   		cmd.CommandText = "SELECT object FROM saved_search  FOR UPDATE ";
23   		//Error Handler
24   		try
25   		{
26   			//Reader
27   			OracleDataReader dr = cmd.ExecuteReader();
28   			dr.Read();
30   			//Read BLOB from DataReader
31   			OracleBlob blob = dr.GetOracleBlob(0);
33   			//byte array
34   			byte[] bytes;
36   			//a STUB search just now 
37   			Session.DbConnection = Database.CreateConnection();
38   			//Search Results object with new Search keyword 
39   			Session.SearchResults = new SearchResults(SearchEngine.Search(Session.DbConnection, "searchword"));
41   			//get the byte array
42   			MemoryStream memStream1 = new MemoryStream();
43   			BinaryFormatter formatter = new BinaryFormatter();
45   			//Serializing TargetAssets object
46   			formatter.Serialize(memStream1, Session.SearchResults);
48   			bytes = memStream1.GetBuffer();
49   			memStream1.Close();
50   			//write blob object to Database 
51   			blob.Write(bytes, 0, bytes.Length);
53   			//Commit data and close connection
54   			txn.Commit();
55   			Response.Write("updated to new data");
56   		}
58   		catch( Exception ex )
59   		{
60   			throw new EroApplicationException("error writing session data to Databse", ex);
61   		}
62   		conn.Close();
63   	}
-- "Mark As Answer" if my reply helped you --
2/20/2008 10:53:38 PM 2269 articles. 0 followers. Follow

0 Replies

Similar Articles

[PageSpeed] 19


Similar Artilces:

Unable to insert into text data type column with large string
I am using ASE 12.0 on AIX 4.3. I have a C++ program with embedded sql which inserts a row into a table with a text data type column. When the string to be inserted into the text column is very large, the insert fails. The string is not close to the size that a text data type can hold so I was wondering if there some kind of restriction on the size of a string that can be used when doing an insert into a text data type column. Thanks in advance for any advice you can give. Steve Bottle wrote: > > I am using ASE 12.0 on AIX 4.3. I have a C+...

Max length (32766) of column in DW for text or blob data type?
Hi Folks How can I break through the max length, char(32766), of column Text or Blob Data type in dw? Thanks in advance Nope. You have to use Select/UpdateBlob - it works on both text and blob columns. HTH, R. On Tue, 28 Aug 2001 15:36:22 +0800, in powersoft.public.powerbuilder.general Eric Tam <> wrote: >Hi Folks > >How can I break through the max length, char(32766), of column Text or Blob >Data type in dw? > >Thanks in advance > > ---== Posted via the PFCGuide Web Newsreader ==---

Size of string data type / column with char data type in PB
I use PB8 as front end with MS SQL Server database as back end. There is a column of Text data type in database. That column is able to hold large size of data. I created a datawindow to retrieve data from this column. Then I created a non-visual user object data store using this datawindow as dataobject. There is a multiplelineEdit control on a window which allows user to input pages of text. When the =91SAVE=92 button is clicked, the text should be saved into the table through the datastore. The problem is: the text is truncated after saving. Only about 4034 characters are ...

How do I turn 2 columns of data into 6 columns of data?
I am pulling the Display Name and Fax Number from Active Directory.  It gets put into a datatable, then fed to a DataGrid.  I end up with a format like this: dn fn dn fn dn fn etc. What I need to do is format it like this: dn fn dn fn dn fn dn fn dn fn dn fn I can try a DataList and use <%# DataBinder.Eval(Container.DataItem, "cn" %>, but then the same values would be put in the same place as the code looped through the search results. Does anyone know how to change the actual column layout of a DataGrid or DataList so the data is displayed horizontal...

Modifying data column names and Data types
I'm in the process of converting a rather huge VSAM database into a set of SQL tables. I am using the same data names from the mainframe (like XDB-NAME to RDB-NAME). I load the files using Import Export Data and it makes the tables with such column names as col001, col002, col003, etc... and always sets the data types to varchr(255). And I have to cut and paste the data names from the manframe side to the server side (and the data types to.)  So, is there an easier way to do this? Or am I doomed to cut-n-paste my days a...

How to get data from column with Long data type
How would I go about extrating data using ASP.NET 2.0 from a column whose datatype in oracle is LONG? Contents field of the Oracle table contents has the type longraw          string sql = "SELECT contents FROM Property "              + " WHERE ElementID = :ElementID";        DBCommandWrapper cmd = db.GetSqlStringCommandWrapper(sql);        cmd.AddInParameter("ElementID", DbType.String, ElementID);&nbs...

Limit a data on column with decimal data type
Dear All, How to limit a column with a specific min value and max value ? I'm using edit mask (on edit tab) in datawindow. Thanks Validation expression - use the appropriate number conversion on GetText(). Or use the ItemChanged event, casting the data argument to the appropriate numeric data type. Report Bugs to Sybase: Product Enhancement Requests: On 11/6/2010 12:38 PM, ekologi wrote: > Dear All, > > How to limit a column with a specific min value and max val...

Insert Picture data To Binary Data Column
Can anyone please offer some advice for a novice?  In addition to my methods and properties for uploading full size images i have this code which i am using to try and create a thumbnail image of the uploaded imageand insert that into a binary column in my database. I have tried several methods but i keep getting an invalid argument error cannot convert byte to int when im trying create a byte array to pass to the parameter. The code is in the upload btn click event.                  &nb...

how to combine full-text COLUMN data search w/ full-text CONTENT data search
how can i combine full-text COLUMN data search w/ full-text CONTENT data search? i am trying to access, in a single stored proc, both the full-text COLUMN data(sql server columns) and the full-text CONTENT data(documents in file system). i can successfully access each via there respective data providers; full-text COLUMN data: System.Data.SqlClient full-text CONTENT data: System.Data.OleDb however, i would like to UNION these data requests into a single stored proc, and therefore, thru a single data provider. is it possible to merge these to into a single stored proc and ...

How to display a column data partially but need complete column data for update?
I have a column in my gridview that contains API KEYS for google maps. These keys are huge so i just need to display partial key for viewing purpose. But I need the complete key when user clicks on update button in gridview. How can I achieve this? Any ideas. I am copying part of my gridview aspx code. Rest of the code is coming from my class file for object datasource. <asp:GridView ID="gvDomains" runat="server" DataSourceID="odsDomains" AutoGenerateColumns="False" DataKeyNames="DomainID" Height="147px" Width="30...

Error inserting data into text data type of MSSQL
Here is my code : Public kode As String   Public MyCon As New SqlConnection("server=;uid=sa;pwd=r**secret**2;database=amipka")   Private Sub beforePageLoad()     If Session("login") = "" Then       Response.Redirect("login.aspx")     End If   End Sub   Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load     'Put user code to initialize the page here     Call beforePageLoad()     Response.Cache.SetCa...

how to hide column data but keep column header text
 Hello,i want to hide my column data programmatically (C#) but still keep the column and its header.Like if i have a column with header "Title". All the data in this column must not be visible.any suggestion? Thank you  If it is all the data in a given column, then one way of doing it, would be to change: SELECT A, B, C, TITLE FROM TABLEtoSELECT A, B, C, TITLE, '' AS TITLE2 FROM TABLE Duplicate the Title column and change the data that is displayed in the second to TITLE2. For those that are allowed to see the data, show the first, for those tha...

Identity column data type in Oracle ?
Hi every body, Is there an identity column data type in oracle like MS SQL? Thank you David No. Oracle uses a SEQUENCE. Take a look in the Oracle SQL Reference at the Create Sequence statement and the use of nextval and curval pseudo columns. -- Terry Dykstra (TeamSybase) Please state PB / OS / DB versions in your post. MySybase Search Google: "David JULY" <> wrote in message > Hi every body, > > Is there an identity column data t...

changing grid view data column type AFTER a data bind
Hi there! I have a grid view that I bind to a dataset.  In that dataset I have a few columns, 2 of which are integers.  After binding the data I want to go through each row and change the integer field to a string, and change the value from a number to something more meaningful!I thought about adding a new column and filling it in but the columns all get added to the end of the grid view and the 2 columns i want to change are the 2nd and 3rd column in the grid.Any ideas? CheersMike   I think you could use template column and have the data bound control hidden....

inserting data to text file from database and inserting data back to database from text file
Hello friends.... I am looking for 2 things(using or and sql svr 2000) 1.convert data from sql server 2000 database (say customers table from northwinds database) to a text file(separated by commas or just plain space) 2.Insert the data from text file back to database. Can someone pls give me the detailed code to achieve this....really need this on urgent basis.......Thank You.Gurjeet,England As for detailed code, I won't give you :P however I can tell you one way of doing this (there are multiple ways).The way I'd do it would be simple:Retrieve the information fr...

Web resources about - Inserting BLOB Type column data with other columns data(normal Text) - SQL Statement -

Inserting Kate
jurvetson posted a photo: the speaking GPS avatar that we came to love.. more prep photos below... You can hear her voice in the video compilation ...

Inserting the Galaxy Note 5’s S Pen backwards can permanently damage the device
One of the features Samsung highlighted when it unveiled the Galaxy Note 5 was the device's new S Pen slot design. The Note 5 features a spring-loaded ...

Inserting Slavery Into The Climate Debate
Chris Hayes compares the fight against fossil fuels to the abolitionist movement. He states plainly that “there is absolutely no conceivable ...

Samsung smart TVs inserting ads into third-party apps
... playback have pissed off a number of consumers. People with smart TVs from Samsung have been complaining that the electronics maker is inserting ...

Inserting images into Gmail could be so much better
When Google first launched the new compact compose window in Gmail, many of you might have noticed something annoying about inserting images. ...

Gawker tells Steven Crowder to "stop whining, take your licks, and accept that getting hit in the face ...
"... in the middle of an argument between billionaire-funded know-nothing ideologues and people whose livelihoods and stability are being threatened ...

Gmail's Shortcut for Inserting Hyperlinks
... but that doesn't mean Google shouldn't improve them. Many people complained that Gmail's rich text editor doesn't have a shortcut for inserting ...

Why Hollywood Is Inserting These Two Huge Chinese Actresses Into Its Summer Blockbusters
... It shows the enormous potential in China for distributors. We've previously discussed how Hollywood is starting to cater to China by inserting ...

Samsung SmartTVs are inserting ads into movies - Business Insider
Random Pepsi pop-up ads have been appearing when SmartTV users watch content through the device's third-party apps.

Resources last updated: 12/30/2015 8:28:20 AM