Click here to Skip to main content
15,920,217 members
Home / Discussions / C#
   

C#

 
GeneralRe: NDoc: dead or alive? [modified] Pin
spin vector2-Oct-06 7:08
spin vector2-Oct-06 7:08 
GeneralRe: NDoc: dead or alive? Pin
Stefan Troschuetz2-Oct-06 7:24
Stefan Troschuetz2-Oct-06 7:24 
GeneralRe: NDoc: dead or alive? Pin
spin vector2-Oct-06 7:25
spin vector2-Oct-06 7:25 
QuestionFull screen form - disabling the Task Bar Pin
srev2-Oct-06 5:45
srev2-Oct-06 5:45 
AnswerRe: Full screen form - disabling the Task Bar Pin
Judah Gabriel Himango2-Oct-06 5:53
sponsorJudah Gabriel Himango2-Oct-06 5:53 
GeneralRe: Full screen form - disabling the Task Bar Pin
srev2-Oct-06 5:59
srev2-Oct-06 5:59 
GeneralRe: Full screen form - disabling the Task Bar Pin
eggie52-Oct-06 8:50
eggie52-Oct-06 8:50 
QuestionRetrieving Stored Proecedure return columns Pin
Jamie Nordmeyer2-Oct-06 5:34
Jamie Nordmeyer2-Oct-06 5:34 
I'm not sure if I should be using this forum or the SQL Server forum, but I'll start here. I have been tasked with writing a project that, as part of its duties, will attach to a SQL Server database (2000 now, 2005 in the near future), and retrieve the columns that a stored procedure will return. I'm using the OleDB provider on purpose, as opposed to System.Data.SqlClient, because of the possible future need to support other systems. Currently, I'm doing the following:

<br />
 private DataTable GetFields()<br />
        {<br />
            DataTable tbl = new DataTable();<br />
<br />
            using (OleDbConnection conn = new OleDbConnection(txtConnectionString.Text))<br />
            {<br />
                try<br />
                {<br />
                    conn.Open();<br />
<br />
                    using (OleDbCommand cmd = new OleDbCommand())<br />
                    {<br />
                        cmd.Connection = conn;<br />
                        if (cmbStoredProcedures.SelectedIndex > 0)<br />
                        {<br />
                            cmd.CommandType = CommandType.StoredProcedure;<br />
                            cmd.CommandText = cmbStoredProcedures.GetItemText(cmbStoredProcedures.SelectedItem);<br />
                        }<br />
                        else<br />
                            cmd.CommandText = txtQuery.Text;<br />
<br />
                        using (OleDbDataAdapter adapter = new OleDbDataAdapter(cmd))<br />
                            adapter.FillSchema(tbl, SchemaType.Source);<br />
                    }<br />
                }<br />
                catch (Exception Ex)<br />
                {<br />
                    MessageBox.Show(Ex.Message);<br />
                }<br />
                finally<br />
                {<br />
                    if (conn.State == ConnectionState.Open) conn.Close();<br />
                }<br />
             }<br />
             return tbl;<br />
          }<br />


My question is this: Is there a better/more efficient way of doing this, or is this really the best way?



Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan
Portland, Oregon, USA

AnswerRe: Retrieving Stored Proecedure return columns Pin
Judah Gabriel Himango2-Oct-06 6:05
sponsorJudah Gabriel Himango2-Oct-06 6:05 
GeneralRe: Retrieving Stored Proecedure return columns Pin
Jamie Nordmeyer2-Oct-06 7:06
Jamie Nordmeyer2-Oct-06 7:06 
QuestionOnFocus Method Issues Pin
Sam Heller2-Oct-06 5:19
Sam Heller2-Oct-06 5:19 
QuestionAPI hooking Pin
bayfouinc2-Oct-06 5:12
bayfouinc2-Oct-06 5:12 
AnswerRe: API hooking Pin
Judah Gabriel Himango2-Oct-06 6:07
sponsorJudah Gabriel Himango2-Oct-06 6:07 
QuestionThe difference between.... Pin
Mark062-Oct-06 4:50
Mark062-Oct-06 4:50 
AnswerRe: The difference between.... Pin
Judah Gabriel Himango2-Oct-06 5:03
sponsorJudah Gabriel Himango2-Oct-06 5:03 
GeneralRe: The difference between.... Pin
Mark062-Oct-06 5:14
Mark062-Oct-06 5:14 
GeneralRe: The difference between.... Pin
Judah Gabriel Himango2-Oct-06 5:32
sponsorJudah Gabriel Himango2-Oct-06 5:32 
AnswerRe: The difference between.... Pin
Judah Gabriel Himango2-Oct-06 5:13
sponsorJudah Gabriel Himango2-Oct-06 5:13 
QuestionNewbie! Search a string for a specific character? Pin
hristo19772-Oct-06 4:21
hristo19772-Oct-06 4:21 
AnswerRe: Newbie! Search a string for a specific character? Pin
Ranjan Banerji2-Oct-06 4:26
Ranjan Banerji2-Oct-06 4:26 
GeneralRe: Newbie! Search a string for a specific character? Pin
hristo19772-Oct-06 4:50
hristo19772-Oct-06 4:50 
GeneralRe: Newbie! Search a string for a specific character? Pin
User 66582-Oct-06 5:00
User 66582-Oct-06 5:00 
GeneralRe: Newbie! Search a string for a specific character? Pin
Judah Gabriel Himango2-Oct-06 5:09
sponsorJudah Gabriel Himango2-Oct-06 5:09 
GeneralRe: Newbie! Search a string for a specific character? Pin
hristo19772-Oct-06 6:32
hristo19772-Oct-06 6:32 
Questionxml martkup of C# code Pin
spin vector2-Oct-06 4:11
spin vector2-Oct-06 4:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.