Update stand alone sql table

1237
6
07-21-2020 11:09 AM
helenchu
Occasional Contributor II

Hi,

I'd like to update my stand alone sql table base on values returned from my selection set.  I was able to get the selection part but I couldn't find any snippets for updating sql table.  Thank you for your help.  Your help is greatly appreciated.  

0 Kudos
6 Replies
RichRuh
Esri Regular Contributor

Hi Helen,

Just to clarify, when you say "stand alone sql table base" are you referring to a table in a database and not a geodatabase?  That is, a database that has not been registered as a geodatabase?

--Rich

0 Kudos
helenchu
Occasional Contributor II

Correct it's just a sql table in database NOT a geodatabase.  My end goal to to have a sql table with a common field with my feature layer and the two joined so I can label my feature layer using a field from the sql table since I'm not allowed to edit the feature layer.  

Or is there a better way to achieve what I need to do?  Thank you Rich.

0 Kudos
RichRuh
Esri Regular Contributor

The Pro SDK doesn't allow you to edit non-geodatabase tables.  You could either add that SQL table to a geodatabase, or edit it using non-ArcGIS routines.

The easiest solution would be to register the table with a geodatabase?  Is there a reason you cannot do this?

--Rich

p.s. Technically, you can also edit a non-geodatabasea table if it is published as part of a feature service, but that seems like using a sledgehammer to hang a picture frame.

0 Kudos
helenchu
Occasional Contributor II

Hi Rich,

I'm a little confused here so let's clarify more about my table.  

Yes I can have my table live inside a geodatabase but my table is just a tabular table.  

In ArcObjects for Arcmap addin, I used these codes to update a sql table doesn't matter where my table is.  So you say in ProSDK I can no longer do that?  Thanks Rich!

        Dim sqlConnection As New SqlConnection(sConStr)

        Dim cmdUpdate As New SqlCommand

        cmdUpdate.Connection = sqlConnection

        cmdUpdate.CommandType = CommandType.StoredProcedure

        cmdUpdate.CommandText = "sp_CalculateRate"

        cmdUpdate.Parameters.Add(New SqlParameter With {.ParameterName = "@ABCD", .SqlDbType = SqlDbType.VarChar, .Value = strABCD})

        cmdUpdate.Parameters.Add(New SqlParameter With {.ParameterName = "@EFGH", .SqlDbType = SqlDbType.VarChar, .Value = strEFGH})

        sqlConnection.Open()

        cmdUpdate.ExecuteNonQuery()

        cmdUpdate.Dispose()

        sqlConnection.Close()

0 Kudos
RichRuh
Esri Regular Contributor

Helen,

The code you have listed, using the SqlConnection and SqlCommand classes, comes from a Microsoft library, not from ArcObjects.  You can continue to use it just fine.

--Rich

0 Kudos
helenchu
Occasional Contributor II

Thanks Rich!

0 Kudos