Using Strata Frame's connection to the datasource...


Author
Message
StarkMike
StarkMike
Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)
Group: Forum Members
Posts: 436, Visits: 944
How do i use the connection to the database that strataframe has made to execute miscellaneous sql? select statements, stored procedures, etc.
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
It depends on what you are trying to do.  All business objects can execute any SQL statement, Stored Procedure, etc.  A business object has the following methods:

FillDataTable()
FillByStoredProcedure()
ExecuteNonQuery()
ExecuteScalar()

and so on... you can look at these through the BO and get a general idea.  If you want to talk straight to the server through the DAL (Data Access Layer) then you will need to do the following:

MicroFour.StrataFrame.Data.DataBasics.DataSources("").ExecuteNonQuery("")

MicroFour.StrataFrame.Data.DataBasics.DataSources("").GetDataTable("", Nothing)

MicroFour.StrataFrame.Data.DataBasics.DataSources("").ExecuteStoredProcedure("", StrataFrame.Data.DbCommandExecutionType.ExecuteNonQuery, Nothing)

MicroFour.StrataFrame.Data.DataBasics.DataSources("").ExecuteScalar("")

Let me know if this doesn't answer your question.  There is a new help install in the "My Account" area that includes a class library reference that may be helpful.  It will show all properties, events, and methods and a description for each item.

StarkMike
StarkMike
Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)
Group: Forum Members
Posts: 436, Visits: 944
I couldnt see the ExecuteNonQuery method on one of my business objects and how do i know what to specify for the datasources?



Here
.DataSources("")

StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
If you only have one data source, leave it as an empty string, since that is the default.
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
The default datasource it generally always an empty string ("").  The data source depends on what you have defined in your AppMain as a required data source.

MicroFour.StrataFrame.Data.ConnectionManager.AddRequiredDataSourceItem("", "SQL Connection", Data.DataSourceTypeOptions.SqlServer, "StrataFrame", "This connection is used by all design-time components and houses the business object mappings, meta-data, messaging, and localization data.")

The string in red above is the name of the key that you will need to specify.  It determines which connection you want to use when you reference the DataSources collection.


StarkMike
StarkMike
Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)
Group: Forum Members
Posts: 436, Visits: 944
Ok, this was the code I used:

MicroFour.StrataFrame.Data.DataBasics.DataSources("").ExecuteStoredProcedure("STI30DeleteTagsFromInventoryTempByUserID", MicroFour.StrataFrame.Data.DbCommandExecutionType.ExecuteNonQuery, New SqlParameter("@UserID", gobjUser.UserID))




and it worked... however I forgot to specify a parameter that the stored procedure needed, and when the code ran... nothing happened... i didnt get an error message or anything. Why would it not come back and tell me that I had forgot a parameter?
StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Yes, it should have throw an SqlException indicating that a required parameter was not supplied... The stored procedure itself wouldn't have caused an error because it never would have even been executed. 
StarkMike
StarkMike
Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)
Group: Forum Members
Posts: 436, Visits: 944
How do I convert this statement to work like the one below it? So that an object is returned?



MicroFour.StrataFrame.Data.DataBasics.DataSources("").ExecuteScalar().ExecuteStoredProcedure("STI80CreateTagsInInvTempTable", MicroFour.StrataFrame.Data.DbCommandExecutionType.ExecuteScalar, loParams.ToArray)



Dim oResult As Object = SqlHelper.ExecuteScalar(CONNECTION_STRING, CommandType.StoredProcedure, "STI40GetProductID", ProductIDParams.ToArray)



StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Imports MicroFour.StrataFrame.Data

DataBasics.DataSources("").ExecuteStoredProcedure("STI80CreateTagsInInvTempTable", _
    DbCommandExecutionType.ExecuteScalar, loParams.ToArray)

Will work fine.  That method will return an object.


StarkMike
StarkMike
Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)Advanced StrataFrame User (532 reputation)
Group: Forum Members
Posts: 436, Visits: 944
Is it possible for me to bind these to a transaction and roll them back if any of them fail? I wasnt sure if StrataFrame supports transactional updates.



DataBasics.DataSources("").ExecuteStoredProcedure("STI30PostTempTagsToInventory", DbCommandExecutionType.ExecuteNonQuery, loParams.ToArray)

DataBasics.DataSources("").ExecuteStoredProcedure("STI30CreateProductionCosts", DbCommandExecutionType.ExecuteNonQuery, loParams.ToArray)



Thanks
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search