SQL Sequence

3111
2
Jump to solution
11-04-2013 01:29 PM
GregRieck
Occasional Contributor III
Hello,

I have created a stored procedure and a sequence in SQL Express 2012 to return an INTEGER of the "Next ID". Is there a way to call the stored procedure using ArcObjects such that it returns the INT value?

Greg
0 Kudos
1 Solution

Accepted Solutions
ParitoshGupta
New Contributor III
Hi Greg
   I am not sure whether this will help or not but as far as I can understand, you need to fire a sql query to get results using ArcObjects. The suitable interface to do this is ISQLWorkspace.

/* A SQL workspace is a relational database that may or may not be a geodatabase. After creating a workspace with the SqlWorkspaceFactory class (and the IWorkspaceFactory interface), this interface is used to retrieve data in a read-only manner as query classes and query cursors */


http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#/OpenQueryCursor_Method/...

View solution in original post

0 Kudos
2 Replies
ParitoshGupta
New Contributor III
Hi Greg
   I am not sure whether this will help or not but as far as I can understand, you need to fire a sql query to get results using ArcObjects. The suitable interface to do this is ISQLWorkspace.

/* A SQL workspace is a relational database that may or may not be a geodatabase. After creating a workspace with the SqlWorkspaceFactory class (and the IWorkspaceFactory interface), this interface is used to retrieve data in a read-only manner as query classes and query cursors */


http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#/OpenQueryCursor_Method/...
0 Kudos
GregRieck
Occasional Contributor III
Paritosh,

Yes, thank you, that does work. I was surprised to see that just passing in the name of the stored procedure was all that was required.

          ISqlWorkspace sqlws = AnIWorkspace as ISqlWorkspace;
          ICursor cur = sqlws.OpenQueryCursor("YourStoredProcedureName");
          if (cur != null)
          {
            IRow row = cur.NextRow();
            if (row != null)
              return (int)row.get_Value(0);
          }
0 Kudos