Click here to Skip to main content
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 21:22pm
wolfsor564
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)



Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 3 Jul 2012
Copyright © CodeProject, 1999-2014
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