开发者

Using a SQL Function to Format Account info?

开发者 https://www.devze.com 2023-04-10 16:01 出处:网络
I have a SQL function that I am calling in my VB.Net code within a display function.The SQL function will format my account data to include the following results form a Table.

I have a SQL function that I am calling in my VB.Net code within a display function. The SQL function will format my account data to include the following results form a Table.

The table data: "001000011121" (this is the type of structure the data has before formated) So the data table data and vb Properties would be called Myaccount, HerAccount, ThisAccount.

Once the data is pulled and then formatted in the VB.net code it will result into a GridDisplay as as: "001.00.001.1121"

The way I have my Public Function in my code is:

Public Funcion GetDisplay(_
ByVal dbBass as DataProvider_
,ByVal pps AS TMGDatarequestParms_
,By filter As IFilter_
) As Ilist

Dim strobe As String = CType(parms.OptionalParameters,  DataProvider).Database

Dim sql As BiGSqlBuilder(TABLE)
sql.Select = String.Form开发者_StackOverflow中文版at("ID, [{0}].dbo.GLForamtAcct(Myaccount) AS [Myaccount], [{0}].dbo.GLFormatAccount(HerAccount) AS [HerAccount], [{0}].dbo.GLFormatAccount(ThisAccount) AS [ThisAccount]", strobe)

I left out some of the return code since not necessary. The only thing I'm concerned is how to format the SQL within the VB.net Code above. I hope this makes sense I'm new to this whole abstraction stuff. Any help would be Highly appreciated cause I'm pretty sure how I have it above does not work.


Suggest implementing your display code in your higher tiers, rather than burdening your database with this business logic.

It sounds like you're string to use String.Format() to insert the table name in your string. This syntax of database.schema.object is really only needed if performing cross database calls.

If you really want to use your SQL UDF to perform your formatting, suggest using/formulating a SELECT statement like:

 SELECT ID,
        dbo.GLFormatAccount(Acct1) AS Acct1,
        dbo.GLFormatAccount(Acct2) AS Acct2,
        dbo.GLFormatAccount(Acct3) AS Acct3
 FROM MyTable
0

精彩评论

暂无评论...
验证码 换一张
取 消