This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Execute plain SQL in script

Hi,

I have an SQL query that i very complicate and at the end it returns just 1 or 0.

I need to run it into a script and let me return just the number.

I can achieve that? 

I didn't find any object in vb dell to do that.

The sqlcommand need an sqlconnection object and I don't know how to fill it from identity manger.

 

Parents
  • OK try this code snippet .... put your complicated SQL where the highlighted code is:

    ConnectionString = Connection.GetSingleProperty("dialogDatabase", "connectionstring", "")

                           Dim conData As ConnectData = DbApp.Instance.Connect(ConnectionString)

                           Using conData.Connection

                               Dim cSQL As SqlExecutor = conData.Connection.CreateSqlExecutor(conData.PublicKey)

                               returnValue = CStr(cSQL.SqlExecuteNonQuery(String.Format("update tps_user set tps_deleted = '{0}' where tps_name = '{1}'", "0", dbsUnsAccount.GetValue("AccountName").String)))

                           End Using

                           If returnValue = "1" Then

                           <some code here>

                           End If

Reply
  • OK try this code snippet .... put your complicated SQL where the highlighted code is:

    ConnectionString = Connection.GetSingleProperty("dialogDatabase", "connectionstring", "")

                           Dim conData As ConnectData = DbApp.Instance.Connect(ConnectionString)

                           Using conData.Connection

                               Dim cSQL As SqlExecutor = conData.Connection.CreateSqlExecutor(conData.PublicKey)

                               returnValue = CStr(cSQL.SqlExecuteNonQuery(String.Format("update tps_user set tps_deleted = '{0}' where tps_name = '{1}'", "0", dbsUnsAccount.GetValue("AccountName").String)))

                           End Using

                           If returnValue = "1" Then

                           <some code here>

                           End If

Children
No Data