Click here to Skip to main content
11,647,748 members (66,384 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# SQL database query
How do you write a C# SELECT Cast Query to combine 3 textbox values and save to the database? Example: Given: height = 5 width = 7 unit = feet Answer: Fieldname dimension = 5 x 7 feet
string sql = "SELECT CAST...?"
Posted 2-Jul-12 20:22pm
wolfsor562
Comments
Damith Weerasinghe at 3-Jul-12 3:04am
   
if You need to save the values of text boxes in database, then why you have select sql statement? you need to have insert statement.
Damith Weerasinghe at 3-Jul-12 3:06am
   
Another question, you need to save it as string "5 x 7 feet" or just the value of multiplication like 35?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try select CAST(height AS varchar) + 'X' + CAST(width AS varchar) + unitl
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

string strDimension = (5*7).ToString()+" feet";
string sql = "Insert Into tableX(dimension) values ('"+strDimension +"')
  Permalink  

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

  Print Answers RSS
0 jyo.net 500
1 F-ES Sitecore 410
2 OriginalGriff 322
3 DamithSL 315
4 CPallini 290
0 OriginalGriff 1,342
1 jyo.net 994
2 DamithSL 971
3 Sergey Alexandrovich Kryukov 873
4 CPallini 795


Advertise | Privacy | Mobile
Web04 | 2.8.150804.3 | Last Updated 3 Jul 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100