Click here to Skip to main content
15,905,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In database records as follows

Course   roomno  Dateofcrs
 REO      11     6/7/2013
 MFA      12     6/7/2013
 ERA      13     6/7/2013
 RM       14     6/7/2013
 EFA      21     6/7/2013
 PST      22     6/7/2013
 CL2      23     6/7/2013


i want to insert automatically Floor according to Roomno in the database as follows;

Output as follows;
Roomno     Floor
 11         1stFloor
 12         1stFloor
 13         lstFloor
 14         1stFloor
 21         2ndFloor
 22         2ndFloor
 23         2ndFloor


for that how can i do using c#.

please help me.

Rgds,
Narasiman P.
Posted
Updated 7-Jul-13 22:33pm
v2
Comments
Mukesh Ghosh 8-Jul-13 1:46am    
How floor related to Room No. please elaborate. Your question not yet clear to me.
jaideepsinh 8-Jul-13 1:53am    
Do you store floor detail in other table?
Sadique KT 8-Jul-13 2:02am    
Convert Room No to string and take substring of it
eg:- string FloorNo=stringRoomNo.SubString(0,1);
VICK 8-Jul-13 2:31am    
I think you should cop up all this on the design size.. you can create a dropdown list with Floor numbers and on its selected index changed you can populate other dropdown list by room numbers. and so on....

Create a table named TBL_ROOM like this

SQL
TBL_ROOM
(
  ROOM_ID INT,
  ROOM_NO INT,
  FLOOR_NO INT,
  FLOOR_DISPLAY_NAME VARCHAR(20)
);

Store your room information in this table like this

1 11 1 1stFloor
2 12 1 1stFloor

now simply get a join to this table on ROOM_NO, your porblem shoul get resolved.

Thanks
 
Share this answer
 
v2
Comments
Maciej Los 8-Jul-13 4:46am    
Please, use text formatting...
I see the dependence between number of room and floor level ;)
SQL
SELECT Course, roomno, Dateofcrs, CASE
	WHEN roomno <20 THEN 'firstfloor'
	WHEN roomno >=20 THEN 'secondfloor'
	ELSE 'where am i?'
	END AS [Floor]
FROM TableName
 
Share this answer
 
XML
right way : (try process data in database)
0. use SELECT :
       <pre lang="SQL">SELECT roomno , CONCAT(SUBSTRING ( roomno ,1, 1),'st floor') ... </pre>
1. use Foreign kay for 2 tables
2. use upatede statment in inset-triggers (automaticaly insert)


C# way :
0. expression field c# (dataset)
1. procedure in dataset to process rows [[foreach(row r in tbl )]]
3. use procedure application layer
 
Share this answer
 

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