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

Recommended Answers

All 3 Replies

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() + "'"

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

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

myDatatable.column.add("your columnname")
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.