andrewmanuja
Well-known member
- Joined
- May 30, 2019
- Messages
- 75
- Programming Experience
- Beginner
Hi All,
I am new to visual C# and currently working on developing an application.
I got a data base table which got a integer field named "orderID" and I want to access the data relating to a given integer variable which matches with the respective orderID value.
For example, I have declared a integer variable named "a" and has assign a value as 2 ( int a =2
.
I later want to pass variable values based on the user input and assign it to "a".
I wrote the below C# code to select the data from the table; "SqlDataAdapter sda = new SqlDataAdapter("SELECT orderID, costcentre,drugID,drugname,requestquantity FROM tbl_order WHERE orderID=2", con);"
con refers to the SqlConnection variable.
However, I do not get the desired output with the above code but, do get the records if I statically assign a value as " WHERE orderID =2".
I may have miss something in regards to data conversion and not able to rectify the issue (Please refer the attached screenshot of the code below).
Appreciate a lot in advance if someone in the community could help me with the said issue.
Kind regards,
Andrew
I am new to visual C# and currently working on developing an application.
I got a data base table which got a integer field named "orderID" and I want to access the data relating to a given integer variable which matches with the respective orderID value.
For example, I have declared a integer variable named "a" and has assign a value as 2 ( int a =2
I later want to pass variable values based on the user input and assign it to "a".
I wrote the below C# code to select the data from the table; "SqlDataAdapter sda = new SqlDataAdapter("SELECT orderID, costcentre,drugID,drugname,requestquantity FROM tbl_order WHERE orderID=2", con);"
con refers to the SqlConnection variable.
However, I do not get the desired output with the above code but, do get the records if I statically assign a value as " WHERE orderID =2".
I may have miss something in regards to data conversion and not able to rectify the issue (Please refer the attached screenshot of the code below).
Appreciate a lot in advance if someone in the community could help me with the said issue.
Kind regards,
Andrew