Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 2079

How to access a UDT from outside SAP

$
0
0

Hi experts, I'm trying to access a UDT and display its contents in a DataGridView using C# in MSVS 2013.  I have a successful connection to the database.  The command

 

SELECT * FROM dbo.[@FOAMSPECS]

 

works from both SAP's Query Preview window and from the Microsoft SQL Server Management Studio's query window.  So after much trying to correctly escape the brackets, I came up with this code snippet

 

            OleDbDataReader dr;

 

 

            string SqlCommand = "SELECT * FROM dbo.[[@FOAMSPECS]]]";

 

 

            // Fill listbox with foam specs

            OleDbCommand cmd = new OleDbCommand { CommandText = SqlCommand, Connection = cn };

            try

            {

                dr = cmd.ExecuteReader();

            }

            catch (Exception ex)

            {

                MessageBox.Show("SQL Error ! " + ex.Message);

            }

 

This seems to produce brackets in the right place in the select string but I get this error

SQLError.jpg

What am I missing?


Viewing all articles
Browse latest Browse all 2079

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>