Using SQL statements in the code


Author
Message
Kari Paukku
Kari Paukku
StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)
Group: Forum Members
Posts: 65, Visits: 820
Hi,

I would like to insert an excel-file as a blob into a Oracle-table. The workflow is that the user would look up a contact and the add the file to that contact. For looking up the contact a SF business object is used. After the contact and file has been selected the blob insert could then be done in the code.

What would be the best way to do this? For me a straight INSERT SQL-statement would work fine in this, but how can I refer to the already existing SF-connection?
The language is VB.Net.

TIA,

Kari

Replies
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
You may want to set the PrimaryKeyIsAutoIncrementing to False on the business object if the primary key is not be managed by the server or your primary key is not integer.  If this doesn't help, turn on debug mode to see what is coming and going to the server.  To do this, open your AppMain.vb or program.cs file and add this code below the SetConnections() call inside of the SetDataSources() method.

MicroFour.StrataFrame.Data.DataBasics.DataSources(0).SetDebugOn("c:\temp\mydebug.html",true)

Kari Paukku
Kari Paukku
StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)
Group: Forum Members
Posts: 65, Visits: 820
Hi,

The PrimaryKeyIsAutoIncremented=FALSE helped and took the Oracle error away. Still some problems and I don't quite know what is wrong with the folllowing gode. The error is about "Object reference not set to an instance of an object." when it executes the MyBO.Save(). 

Dim MyBO As New CommunicationBO()

With
MyBO
     .NewRow()
     .PrimaryKeyIsAutoIncremented =
False
     .COMMUNICATION_BLOB = System.IO.File.ReadAllBytes(fd.FileName)
     .FILE_TYPE =
"XLS"
     .FILE_NAME = fd.FileName
End With

MyBO.Save()

But why? Isn't the "Dim MyBO as New CommunicationBO()" enough to create the object or should there be more

Sorry to trouble you with this,

Kari

=== The full error stack  ===
DataLayerSavingException
 Object reference not set to an instance of an object.
NullReferenceException
 Object reference not set to an instance of an object.

Source     : MicroFour StrataFrame Business

Stack Trace:
   at MicroFour.StrataFrame.Data.OracleDataSourceItem.UpdateRow(QueryInformation QueryInfo, DataRow RowToUpdate, ConcurrencyExceptionHandler ConcurrencyHandler, AddRowErrorHandler RowErrorHandler, Boolean RecreateCommand)
   at MicroFour.StrataFrame.Data.DbDataSourceItem.UpdateRow(QueryInformation QueryInfo, DataRow RowToUpdate, ConcurrencyExceptionHandler ConcurrencyHandler, AddRowErrorHandler RowErrorHandler)
   at MicroFour.StrataFrame.Data.DataLayer.UpdateDataTableThread(Object ThreadParams)
   at MicroFour.StrataFrame.Business.BusinessLayer.Save(Boolean Transactional, String TransactionKey)
   at MicroFour.StrataFrame.Business.BusinessLayer.Save()
   at WinLoadClaimForm.w_SchemeCompanyList.Button1_Click(Object sender, EventArgs e) in D:\FALX\Folksam UK\Custom Applications\WinLoadClaimForm\WinLoadClaimForm\WinLoadClaimForm\w_SchemeCompanyList.vb:line 120
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Kari Paukku - 19 Years Ago
Trent L. Taylor - 19 Years Ago
Kari Paukku - 19 Years Ago
Trent L. Taylor - 19 Years Ago
Kari Paukku - 19 Years Ago
Kari Paukku - 19 Years Ago
StrataFrame Team - 19 Years Ago
StrataFrame Team - 19 Years Ago
Kari Paukku - 19 Years Ago
                         Ben, attached is a small application that retrieves data from table...
Kari Paukku - 19 Years Ago
                             OK, Kari, there is no sequence created that you can use for inserting...
StrataFrame Team - 19 Years Ago
                             Hi, just as information, after downloading the latest version of SF...
Kari Paukku - 19 Years Ago
                                 Good to know about that foreign key that exists on the EMPS table....
StrataFrame Team - 19 Years Ago
Kari Paukku - 19 Years Ago
StrataFrame Team - 19 Years Ago
                 Ben, thank you very much. Kari
Kari Paukku - 19 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search