in Education by
As title really. I want to object just one specific value from a colum on one row of a SQL database. The PHP code I would use would be: $result = mysql_query("SELECT price FROM delivery WHERE id='$id'"); echo mysql_result($result,0); That would get me the price from what ever autoinc id I choose. As I'm new to C# its quite tricky to get my head around as there seems to be many different methods to obtain the same results. Any help would be appreciated, thanks! EDIT I'm using System.Data.SqlClient as, so far, its done me proud. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
If data type of PRICE column you want to retrieve is a scalar value and you'll get only one record then I assume the most efficient way would be ExecuteScalar() method. Here's a little sample code: string conString="Data Source=local;Initial Catalog=...." SQLConnection con=new SQLConnection(conString); SQLCommand cmd=new SQLCOmmand("SELECT price FROM delivery WHERE =@ID",con) cmd.Parameters.Add("@ID", SqlDbType.Int).Value=125//Off course it just a sample value con.Open(); float price=(decimal)cmd.ExecuteScalar(); ...... con.Close();//don't forget

Related questions

0 votes
    As title really. I want to object just one specific value from a colum on one row of a SQL ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 3, 2022 in Education by JackTerrance
0 votes
    As title really. I want to object just one specific value from a colum on one row of a SQL ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    As title really. I want to object just one specific value from a colum on one row of a SQL ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    I am trying to paginate the results of an SQL query for use on a web page. The language and the ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 27, 2022 in Education by JackTerrance
0 votes
    Which of the following function can be used to combine different vectors so as to obtain the result for each ... and answers pdf, Data Science interview questions for beginners...
asked Oct 28, 2021 in Education by JackTerrance
0 votes
    Which of the following function can be used to combine different vectors so as to obtain the result for each n-uplet? (a) iid_ (b) ix_ (c) ixd_ (d) all of the mentioned...
asked Oct 5, 2021 in Technology by JackTerrance
0 votes
    I am using autoencoders to do anomaly detection. So, I have finished training my model and now I want to ... y _true and y_pred Select the correct answer from above options...
asked Jan 29, 2022 in Education by JackTerrance
0 votes
    Which is the most efficient way to learn Splunk? Select the correct answer from above options...
asked Jan 6, 2022 in Education by JackTerrance
0 votes
    In what way is the closure compiler efficient? (a) Increases the size of the JavaScript files (b) ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
    Which of the following is an efficient way to securely store passwords? (1)Abstraction (2)Hashing (3)Encryption...
asked May 17, 2021 in General by JackTerrance
0 votes
    A web page displays 10 items per page and has pagination enabled. What would be the recommended way to enable efficient ... (d)Hit the database every time user moves to next page...
asked Oct 6, 2020 in Technology by JackTerrance
0 votes
    What’s the most puzzling programming challenge you have come across recently?...
asked Jun 13, 2021 in Education by Editorial Staff
0 votes
    I would like to ask for performance of SQL. This is my query: Select A.code ,A.name ,(Select B. ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    When SQL run from the other programming language the result will be- 1. Neither DataFrame nor Dataset 2. DataFrame 3. DataSet 4. Either DataFrame or Dataset...
asked Oct 22, 2020 in Technology by JackTerrance
0 votes
    How to obtain the SQL query from the queryset in Django?...
asked Jul 2, 2021 in Technology by JackTerrance
...