Click here to Skip to main content
15,886,788 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hi.
i have two field in my database. code and mark
and i have label in my program that it has number.
i want minus mark from label.text like this "mark-label1.text" where code is 1

I wrote this code but it did not answer.
C#
Dim da As New SqlDataAdapter("select mark-'" + label1.text + "' from Tbl_StudentMark where code='" + 1 + "'", con)

please help me.
Posted
Updated 4-Jul-14 16:35pm
v2
Comments
DamithSL 4-Jul-14 22:33pm    
what is the column data types of mark and code?
It Should Work Normally[^]
Atyant Srivastava 5-Jul-14 0:50am    
Please check what is the final query getting generated from the above code through quick watch and copy that query to sql and see whether it is running. you will get the issue.
Also just want to know what value you label.text is having?

Hi,

Please write in below way

C#
Dim da As New SqlDataAdapter("select (mark-" + label1.text + ") as Balance from Tbl_StudentMark where code='" + 1 + "'", con)
 
Share this answer
 
select datediff(dd,'"+label.text+"',mark) from Tbl_StudentMark where code='" + 1 + "'"


if my query is helpful for u .select my answer as "Accept answer"
 
Share this answer
 
v2
Comments
Atyant Srivastava 5-Jul-14 2:16am    
i suppose this will work for dates only not in the case of integer as mark could be a integer field not a date field.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900