Click here to Skip to main content
13,046,375 members (120,464 online)
Rate this:
Please Sign up or sign in to vote.
See more:
How do you write a C# SELECT Cast Query to combine 3 textbox values and save to the database?


height = 5
width = 7
unit = feet

Fieldname dimension = 5 x 7 feet

string sql = "SELECT CAST...?"
Posted 2-Jul-12 20:22pm
Damith Weerasinghe 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 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
Please Sign up or sign in to vote.

Solution 1

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

Solution 2

string strDimension = (5*7).ToString()+" feet";

string sql = "Insert Into tableX(dimension) values ('"+strDimension +"')

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 3 Jul 2012
Copyright © CodeProject, 1999-2017
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