0

Hi,
i want to create a query which select three columns from a table on certain condition now i have got certain with three columns and i can bind this data to a datagridview but before this i want to add a column to dgv say col_new and fill its cell with a variable value
here's my query
SELECT PID, Name, FName FROM Tbl_Products WHERE PID = '" + PID.ToString()
iwant to do somthing like this
SELECT '"+ Col_New.text +"' PID, Name, FName FROM Tbl_Products WHERE PID = '" + PID.ToString()
and when ill bind my data to dgv then i should get PID Name FName from table and Col_New from variable

3
Contributors
3
Replies
40
Views
4 Years
Discussion Span
Last Post by M.Waqas Aslam
2

So what issue are you having? Not sure exactly what you mean, but In any case, I would think you are missing a comma (and apostrophe at the end) in your second SQL example..

sqlString = "SELECT '"+ Col_New.text +"', PID, Name, FName FROM Tbl_Products WHERE PID = '" + PID.ToString() + "'"

Edited by JorgeM

0

actualy Col_new does not belong to Tbl_Products i want to add an extra column in datatable from textbox value

0

try to do somthing like this ,
after adding all records normally to your datatable , add column like this ,

myDatatable.column.add("your columnname")
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.