Tuesday, May 15, 2012

How to convert string to string[] in C#?

It might happen that you receive from POST a variable name that is in fact an array. So in this case you should convert your object into string[]. How do you do that?
Well, as usually, it is simple:
string[] RoomOptions = new string[] { Request["room_options"] };
So there you are.
This was for solving asp error message saying:
Error message: Cannot convert type 'string' to 'string[]'

Friday, May 11, 2012

How to make an update query using join in SQL

Today it helped me a lot this page which instructed me how to make an update query using join. So you can go and check it out on http://www.bennadel.com/blog/938-Using-A-SQL-JOIN-In-A-SQL-UPDATE-Statement-Thanks-John-Eric-.htm

Here you can see how I wrote my update command:

                        UPDATE  O
set O.Payed = Payed - 1, O.PaymentDate = null , refPaymentMethodId = null
from [Orders] O
join PaymentMethod pm on pm.PaymentMethodID = O.refPaymentMethodID
where OrderID = @OrderID and pm.GenerateReceipt = 1;