sqlcommand c# method with sql paramather The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceHow do I calculate someone's age in C#?Calculate relative time in C#What is the difference between String and string in C#?Hidden Features of C#?Calling the base constructor in C#Cast int to enum in C#How do you give a C# Auto-Property a default value?How do I enumerate an enum in C#?What are the correct version numbers for C#?How do I get a consistent byte representation of strings in C# without manually specifying an encoding?

What was the last x86 CPU that did not have the x87 floating-point unit built in?

Hopping to infinity along a string of digits

How to copy the contents of all files with a certain name into a new file?

Simulating Exploding Dice

Are spiders unable to hurt humans, especially very small spiders?

Do working physicists consider Newtonian mechanics to be "falsified"?

Python - Fishing Simulator

Is every episode of "Where are my Pants?" identical?

How did the audience guess the pentatonic scale in Bobby McFerrin's presentation?

He got a vote 80% that of Emmanuel Macron’s

Scientific Reports - Significant Figures

Does the AirPods case need to be around while listening via an iOS Device?

How do you keep chess fun when your opponent constantly beats you?

Arduino Pro Micro - switch off LEDs

How to delete random line from file using Unix command?

Still taught to reverse oxidation half cells in electrochemistry?

How can I protect witches in combat who wear limited clothing?

Make it rain characters

Is there a writing software that you can sort scenes like slides in PowerPoint?

Why does the Event Horizon Telescope (EHT) not include telescopes from Africa, Asia or Australia?

How are presidential pardons supposed to be used?

Typeface like Times New Roman but with "tied" percent sign

How do I add random spotting to the same face in cycles?

University's motivation for having tenure-track positions



sqlcommand c# method with sql paramather



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experienceHow do I calculate someone's age in C#?Calculate relative time in C#What is the difference between String and string in C#?Hidden Features of C#?Calling the base constructor in C#Cast int to enum in C#How do you give a C# Auto-Property a default value?How do I enumerate an enum in C#?What are the correct version numbers for C#?How do I get a consistent byte representation of strings in C# without manually specifying an encoding?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I have this method, which I have in the base class that helps me to select anything from the children classes and also to reduce code repetition. The problem is when I call it I get an error which is a NullReferenceException (and when I look it up I find that the command in the method is empty).
This is the method in question:
This way I already know how to use but the other one I don't



SqlCommand command = new SqlCommand("select * from Customers where idCustomer=@idCustomer", OpenConnection());
command.Parameters.AddWithValue("@idCustomer", Id);
SqlDataReader reader = command.ExecuteReader();
Customer Onecustomer = null;
if (reader.Read())

Onecustomer = ReadCustomer(reader);




protected DataTable ExecuteSelectQuery(String query, params SqlParameter[] sqlParameters)

SqlCommand command = new SqlCommand();
DataTable dataTable;
DataSet dataSet = new DataSet();

try

command.Connection = OpenConnection();
command.CommandText = query;
command.Parameters.AddRange(sqlParameters);
command.ExecuteNonQuery();
adapter.SelectCommand = command;
adapter.Fill(dataSet);
dataTable = dataSet.Tables[0];

catch (SqlException e)

return null;
throw new Exception("Error :" + e.Message);

finally

CloseConnection();

return dataTable;



Here how I call it



string author = "Alfred Schmidt";
int id = 1;

// ExecuteEditQuery("UPDATE Books SET Title =@param1 WHERE idBook =@param2", sqlParameters);
//SqlParameter[] sqlParameters = new SqlParameter[1]
//
// new SqlParameter ("@param1",author),
//;

SqlParameter[] myparm = new SqlParameter[1];
myparm[0] = new SqlParameter("@Author", SqlDbType.NVarChar, 200);
myparm[0].Value = author;

String query = @"SELECT * FROM Books WHERE Author =@Author";
DataTable dt = ExecuteSelectQuery(query, myparm);

for (int i = 0; i < dt.Rows.Count; i++)

Console.WriteLine(dt.Rows.ToString());

Console.Write("");


1










share|improve this question



















  • 1





    adapter is not defined anywhere in the code you have posted? - The command.ExecuteNonQuery(); should not be there, remove it, SqlCommand implements IDisposable so should be withn a using block.

    – Alex K.
    Mar 8 at 12:49

















1















I have this method, which I have in the base class that helps me to select anything from the children classes and also to reduce code repetition. The problem is when I call it I get an error which is a NullReferenceException (and when I look it up I find that the command in the method is empty).
This is the method in question:
This way I already know how to use but the other one I don't



SqlCommand command = new SqlCommand("select * from Customers where idCustomer=@idCustomer", OpenConnection());
command.Parameters.AddWithValue("@idCustomer", Id);
SqlDataReader reader = command.ExecuteReader();
Customer Onecustomer = null;
if (reader.Read())

Onecustomer = ReadCustomer(reader);




protected DataTable ExecuteSelectQuery(String query, params SqlParameter[] sqlParameters)

SqlCommand command = new SqlCommand();
DataTable dataTable;
DataSet dataSet = new DataSet();

try

command.Connection = OpenConnection();
command.CommandText = query;
command.Parameters.AddRange(sqlParameters);
command.ExecuteNonQuery();
adapter.SelectCommand = command;
adapter.Fill(dataSet);
dataTable = dataSet.Tables[0];

catch (SqlException e)

return null;
throw new Exception("Error :" + e.Message);

finally

CloseConnection();

return dataTable;



Here how I call it



string author = "Alfred Schmidt";
int id = 1;

// ExecuteEditQuery("UPDATE Books SET Title =@param1 WHERE idBook =@param2", sqlParameters);
//SqlParameter[] sqlParameters = new SqlParameter[1]
//
// new SqlParameter ("@param1",author),
//;

SqlParameter[] myparm = new SqlParameter[1];
myparm[0] = new SqlParameter("@Author", SqlDbType.NVarChar, 200);
myparm[0].Value = author;

String query = @"SELECT * FROM Books WHERE Author =@Author";
DataTable dt = ExecuteSelectQuery(query, myparm);

for (int i = 0; i < dt.Rows.Count; i++)

Console.WriteLine(dt.Rows.ToString());

Console.Write("");


1










share|improve this question



















  • 1





    adapter is not defined anywhere in the code you have posted? - The command.ExecuteNonQuery(); should not be there, remove it, SqlCommand implements IDisposable so should be withn a using block.

    – Alex K.
    Mar 8 at 12:49













1












1








1








I have this method, which I have in the base class that helps me to select anything from the children classes and also to reduce code repetition. The problem is when I call it I get an error which is a NullReferenceException (and when I look it up I find that the command in the method is empty).
This is the method in question:
This way I already know how to use but the other one I don't



SqlCommand command = new SqlCommand("select * from Customers where idCustomer=@idCustomer", OpenConnection());
command.Parameters.AddWithValue("@idCustomer", Id);
SqlDataReader reader = command.ExecuteReader();
Customer Onecustomer = null;
if (reader.Read())

Onecustomer = ReadCustomer(reader);




protected DataTable ExecuteSelectQuery(String query, params SqlParameter[] sqlParameters)

SqlCommand command = new SqlCommand();
DataTable dataTable;
DataSet dataSet = new DataSet();

try

command.Connection = OpenConnection();
command.CommandText = query;
command.Parameters.AddRange(sqlParameters);
command.ExecuteNonQuery();
adapter.SelectCommand = command;
adapter.Fill(dataSet);
dataTable = dataSet.Tables[0];

catch (SqlException e)

return null;
throw new Exception("Error :" + e.Message);

finally

CloseConnection();

return dataTable;



Here how I call it



string author = "Alfred Schmidt";
int id = 1;

// ExecuteEditQuery("UPDATE Books SET Title =@param1 WHERE idBook =@param2", sqlParameters);
//SqlParameter[] sqlParameters = new SqlParameter[1]
//
// new SqlParameter ("@param1",author),
//;

SqlParameter[] myparm = new SqlParameter[1];
myparm[0] = new SqlParameter("@Author", SqlDbType.NVarChar, 200);
myparm[0].Value = author;

String query = @"SELECT * FROM Books WHERE Author =@Author";
DataTable dt = ExecuteSelectQuery(query, myparm);

for (int i = 0; i < dt.Rows.Count; i++)

Console.WriteLine(dt.Rows.ToString());

Console.Write("");


1










share|improve this question
















I have this method, which I have in the base class that helps me to select anything from the children classes and also to reduce code repetition. The problem is when I call it I get an error which is a NullReferenceException (and when I look it up I find that the command in the method is empty).
This is the method in question:
This way I already know how to use but the other one I don't



SqlCommand command = new SqlCommand("select * from Customers where idCustomer=@idCustomer", OpenConnection());
command.Parameters.AddWithValue("@idCustomer", Id);
SqlDataReader reader = command.ExecuteReader();
Customer Onecustomer = null;
if (reader.Read())

Onecustomer = ReadCustomer(reader);




protected DataTable ExecuteSelectQuery(String query, params SqlParameter[] sqlParameters)

SqlCommand command = new SqlCommand();
DataTable dataTable;
DataSet dataSet = new DataSet();

try

command.Connection = OpenConnection();
command.CommandText = query;
command.Parameters.AddRange(sqlParameters);
command.ExecuteNonQuery();
adapter.SelectCommand = command;
adapter.Fill(dataSet);
dataTable = dataSet.Tables[0];

catch (SqlException e)

return null;
throw new Exception("Error :" + e.Message);

finally

CloseConnection();

return dataTable;



Here how I call it



string author = "Alfred Schmidt";
int id = 1;

// ExecuteEditQuery("UPDATE Books SET Title =@param1 WHERE idBook =@param2", sqlParameters);
//SqlParameter[] sqlParameters = new SqlParameter[1]
//
// new SqlParameter ("@param1",author),
//;

SqlParameter[] myparm = new SqlParameter[1];
myparm[0] = new SqlParameter("@Author", SqlDbType.NVarChar, 200);
myparm[0].Value = author;

String query = @"SELECT * FROM Books WHERE Author =@Author";
DataTable dt = ExecuteSelectQuery(query, myparm);

for (int i = 0; i < dt.Rows.Count; i++)

Console.WriteLine(dt.Rows.ToString());

Console.Write("");


1







c# sqlcommand mysql-parameter






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 13:21









Kristóf Tóth

520314




520314










asked Mar 8 at 12:40









user3560798user3560798

92




92







  • 1





    adapter is not defined anywhere in the code you have posted? - The command.ExecuteNonQuery(); should not be there, remove it, SqlCommand implements IDisposable so should be withn a using block.

    – Alex K.
    Mar 8 at 12:49












  • 1





    adapter is not defined anywhere in the code you have posted? - The command.ExecuteNonQuery(); should not be there, remove it, SqlCommand implements IDisposable so should be withn a using block.

    – Alex K.
    Mar 8 at 12:49







1




1





adapter is not defined anywhere in the code you have posted? - The command.ExecuteNonQuery(); should not be there, remove it, SqlCommand implements IDisposable so should be withn a using block.

– Alex K.
Mar 8 at 12:49





adapter is not defined anywhere in the code you have posted? - The command.ExecuteNonQuery(); should not be there, remove it, SqlCommand implements IDisposable so should be withn a using block.

– Alex K.
Mar 8 at 12:49












2 Answers
2






active

oldest

votes


















0














Is your OpenConnection() method returns a connection object. It may couse the error, the implementation of the method is not given. Also the adpater is not defined in the code, may be it can be the cause of error too, if it is not initialized.



And i want to say few things about your code:



1) You have and unnecessary command.ExecuteNonQuery(); statement in your ExecuteSelectQuery method.



2) DataAdapter can directly fill DataTable, you dont have to use DataSet.






share|improve this answer






























    0














    Here's a proper rewrite of your method.



    protected DataTable ExecuteSelectQuery(String query, params SqlParameter[] sqlParameters)

    using (SqlCommand command = new SqlCommand())
    try

    command.CommandText = query;
    command.Parameters.AddRange(sqlParameters);
    command.Connection = OpenConnection();

    DataTable dataTable = new DataTable();
    using (SqlDataAdapter adapter = new SqlDataAdapter(command))
    adapter.Fill(dataTable);
    return dataTable;

    catch (SqlException e)

    return null;
    throw new Exception("Error :" + e.Message);

    finally

    CloseConnection();





    Note that the SqlDataAdapter can Open() and Close() the connection by itself, if the SqlConnection is Closed when Fill is called.






    share|improve this answer

























    • If you're throwing an exception already in your catch, which will stop execution, what's the point of having return null; ? That seems as though the exception is unreachable since the method exists first?

      – Symon
      Mar 8 at 13:36












    • @Symon copied from the question, and yes, it's unreachable right now. It should also contain the SqlException as an InnerException and possibly be using ApplicationException instead of the Exception base class.

      – Mikael Dúi Bolinder
      Mar 8 at 13:40












    • Thank you fro the explaination . now if i want to call this method and give args to it how i can do this ?? like i prepare a query and paramter list but i dont know how to do it .

      – user3560798
      Mar 8 at 15:33











    • @user3560798 Call it like you do in you question, var resultTable = ExecuteSelectQuery(query, parameters);.

      – Mikael Dúi Bolinder
      Mar 8 at 15:57











    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55063442%2fsqlcommand-c-sharp-method-with-sql-paramather%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Is your OpenConnection() method returns a connection object. It may couse the error, the implementation of the method is not given. Also the adpater is not defined in the code, may be it can be the cause of error too, if it is not initialized.



    And i want to say few things about your code:



    1) You have and unnecessary command.ExecuteNonQuery(); statement in your ExecuteSelectQuery method.



    2) DataAdapter can directly fill DataTable, you dont have to use DataSet.






    share|improve this answer



























      0














      Is your OpenConnection() method returns a connection object. It may couse the error, the implementation of the method is not given. Also the adpater is not defined in the code, may be it can be the cause of error too, if it is not initialized.



      And i want to say few things about your code:



      1) You have and unnecessary command.ExecuteNonQuery(); statement in your ExecuteSelectQuery method.



      2) DataAdapter can directly fill DataTable, you dont have to use DataSet.






      share|improve this answer

























        0












        0








        0







        Is your OpenConnection() method returns a connection object. It may couse the error, the implementation of the method is not given. Also the adpater is not defined in the code, may be it can be the cause of error too, if it is not initialized.



        And i want to say few things about your code:



        1) You have and unnecessary command.ExecuteNonQuery(); statement in your ExecuteSelectQuery method.



        2) DataAdapter can directly fill DataTable, you dont have to use DataSet.






        share|improve this answer













        Is your OpenConnection() method returns a connection object. It may couse the error, the implementation of the method is not given. Also the adpater is not defined in the code, may be it can be the cause of error too, if it is not initialized.



        And i want to say few things about your code:



        1) You have and unnecessary command.ExecuteNonQuery(); statement in your ExecuteSelectQuery method.



        2) DataAdapter can directly fill DataTable, you dont have to use DataSet.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 8 at 12:58









        emumcuemumcu

        438




        438























            0














            Here's a proper rewrite of your method.



            protected DataTable ExecuteSelectQuery(String query, params SqlParameter[] sqlParameters)

            using (SqlCommand command = new SqlCommand())
            try

            command.CommandText = query;
            command.Parameters.AddRange(sqlParameters);
            command.Connection = OpenConnection();

            DataTable dataTable = new DataTable();
            using (SqlDataAdapter adapter = new SqlDataAdapter(command))
            adapter.Fill(dataTable);
            return dataTable;

            catch (SqlException e)

            return null;
            throw new Exception("Error :" + e.Message);

            finally

            CloseConnection();





            Note that the SqlDataAdapter can Open() and Close() the connection by itself, if the SqlConnection is Closed when Fill is called.






            share|improve this answer

























            • If you're throwing an exception already in your catch, which will stop execution, what's the point of having return null; ? That seems as though the exception is unreachable since the method exists first?

              – Symon
              Mar 8 at 13:36












            • @Symon copied from the question, and yes, it's unreachable right now. It should also contain the SqlException as an InnerException and possibly be using ApplicationException instead of the Exception base class.

              – Mikael Dúi Bolinder
              Mar 8 at 13:40












            • Thank you fro the explaination . now if i want to call this method and give args to it how i can do this ?? like i prepare a query and paramter list but i dont know how to do it .

              – user3560798
              Mar 8 at 15:33











            • @user3560798 Call it like you do in you question, var resultTable = ExecuteSelectQuery(query, parameters);.

              – Mikael Dúi Bolinder
              Mar 8 at 15:57















            0














            Here's a proper rewrite of your method.



            protected DataTable ExecuteSelectQuery(String query, params SqlParameter[] sqlParameters)

            using (SqlCommand command = new SqlCommand())
            try

            command.CommandText = query;
            command.Parameters.AddRange(sqlParameters);
            command.Connection = OpenConnection();

            DataTable dataTable = new DataTable();
            using (SqlDataAdapter adapter = new SqlDataAdapter(command))
            adapter.Fill(dataTable);
            return dataTable;

            catch (SqlException e)

            return null;
            throw new Exception("Error :" + e.Message);

            finally

            CloseConnection();





            Note that the SqlDataAdapter can Open() and Close() the connection by itself, if the SqlConnection is Closed when Fill is called.






            share|improve this answer

























            • If you're throwing an exception already in your catch, which will stop execution, what's the point of having return null; ? That seems as though the exception is unreachable since the method exists first?

              – Symon
              Mar 8 at 13:36












            • @Symon copied from the question, and yes, it's unreachable right now. It should also contain the SqlException as an InnerException and possibly be using ApplicationException instead of the Exception base class.

              – Mikael Dúi Bolinder
              Mar 8 at 13:40












            • Thank you fro the explaination . now if i want to call this method and give args to it how i can do this ?? like i prepare a query and paramter list but i dont know how to do it .

              – user3560798
              Mar 8 at 15:33











            • @user3560798 Call it like you do in you question, var resultTable = ExecuteSelectQuery(query, parameters);.

              – Mikael Dúi Bolinder
              Mar 8 at 15:57













            0












            0








            0







            Here's a proper rewrite of your method.



            protected DataTable ExecuteSelectQuery(String query, params SqlParameter[] sqlParameters)

            using (SqlCommand command = new SqlCommand())
            try

            command.CommandText = query;
            command.Parameters.AddRange(sqlParameters);
            command.Connection = OpenConnection();

            DataTable dataTable = new DataTable();
            using (SqlDataAdapter adapter = new SqlDataAdapter(command))
            adapter.Fill(dataTable);
            return dataTable;

            catch (SqlException e)

            return null;
            throw new Exception("Error :" + e.Message);

            finally

            CloseConnection();





            Note that the SqlDataAdapter can Open() and Close() the connection by itself, if the SqlConnection is Closed when Fill is called.






            share|improve this answer















            Here's a proper rewrite of your method.



            protected DataTable ExecuteSelectQuery(String query, params SqlParameter[] sqlParameters)

            using (SqlCommand command = new SqlCommand())
            try

            command.CommandText = query;
            command.Parameters.AddRange(sqlParameters);
            command.Connection = OpenConnection();

            DataTable dataTable = new DataTable();
            using (SqlDataAdapter adapter = new SqlDataAdapter(command))
            adapter.Fill(dataTable);
            return dataTable;

            catch (SqlException e)

            return null;
            throw new Exception("Error :" + e.Message);

            finally

            CloseConnection();





            Note that the SqlDataAdapter can Open() and Close() the connection by itself, if the SqlConnection is Closed when Fill is called.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Mar 8 at 13:27

























            answered Mar 8 at 13:22









            Mikael Dúi BolinderMikael Dúi Bolinder

            1,36011031




            1,36011031












            • If you're throwing an exception already in your catch, which will stop execution, what's the point of having return null; ? That seems as though the exception is unreachable since the method exists first?

              – Symon
              Mar 8 at 13:36












            • @Symon copied from the question, and yes, it's unreachable right now. It should also contain the SqlException as an InnerException and possibly be using ApplicationException instead of the Exception base class.

              – Mikael Dúi Bolinder
              Mar 8 at 13:40












            • Thank you fro the explaination . now if i want to call this method and give args to it how i can do this ?? like i prepare a query and paramter list but i dont know how to do it .

              – user3560798
              Mar 8 at 15:33











            • @user3560798 Call it like you do in you question, var resultTable = ExecuteSelectQuery(query, parameters);.

              – Mikael Dúi Bolinder
              Mar 8 at 15:57

















            • If you're throwing an exception already in your catch, which will stop execution, what's the point of having return null; ? That seems as though the exception is unreachable since the method exists first?

              – Symon
              Mar 8 at 13:36












            • @Symon copied from the question, and yes, it's unreachable right now. It should also contain the SqlException as an InnerException and possibly be using ApplicationException instead of the Exception base class.

              – Mikael Dúi Bolinder
              Mar 8 at 13:40












            • Thank you fro the explaination . now if i want to call this method and give args to it how i can do this ?? like i prepare a query and paramter list but i dont know how to do it .

              – user3560798
              Mar 8 at 15:33











            • @user3560798 Call it like you do in you question, var resultTable = ExecuteSelectQuery(query, parameters);.

              – Mikael Dúi Bolinder
              Mar 8 at 15:57
















            If you're throwing an exception already in your catch, which will stop execution, what's the point of having return null; ? That seems as though the exception is unreachable since the method exists first?

            – Symon
            Mar 8 at 13:36






            If you're throwing an exception already in your catch, which will stop execution, what's the point of having return null; ? That seems as though the exception is unreachable since the method exists first?

            – Symon
            Mar 8 at 13:36














            @Symon copied from the question, and yes, it's unreachable right now. It should also contain the SqlException as an InnerException and possibly be using ApplicationException instead of the Exception base class.

            – Mikael Dúi Bolinder
            Mar 8 at 13:40






            @Symon copied from the question, and yes, it's unreachable right now. It should also contain the SqlException as an InnerException and possibly be using ApplicationException instead of the Exception base class.

            – Mikael Dúi Bolinder
            Mar 8 at 13:40














            Thank you fro the explaination . now if i want to call this method and give args to it how i can do this ?? like i prepare a query and paramter list but i dont know how to do it .

            – user3560798
            Mar 8 at 15:33





            Thank you fro the explaination . now if i want to call this method and give args to it how i can do this ?? like i prepare a query and paramter list but i dont know how to do it .

            – user3560798
            Mar 8 at 15:33













            @user3560798 Call it like you do in you question, var resultTable = ExecuteSelectQuery(query, parameters);.

            – Mikael Dúi Bolinder
            Mar 8 at 15:57





            @user3560798 Call it like you do in you question, var resultTable = ExecuteSelectQuery(query, parameters);.

            – Mikael Dúi Bolinder
            Mar 8 at 15:57

















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55063442%2fsqlcommand-c-sharp-method-with-sql-paramather%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

            Алба-Юлія

            Захаров Федір Захарович