Parameters with SQL IN operator
-
Hi all, How can use the IN Operator with Parameters. Any Example will be helpfull Thanks Dana
-
Hi all, How can use the IN Operator with Parameters. Any Example will be helpfull Thanks Dana
Hello Dana, The values that do not fit into a neat range, we use the IN operator. An example would be: Select * from Customers Where CustID IN (1, 3, 5); The above query will give us rows for CustID 1, 3 and 5 from the Customer's table. Regards, Dave
Dave Traister Software Engineer ComponentOne LLC www.ComponentOne.com
-
Hello Dana, The values that do not fit into a neat range, we use the IN operator. An example would be: Select * from Customers Where CustID IN (1, 3, 5); The above query will give us rows for CustID 1, 3 and 5 from the Customer's table. Regards, Dave
Dave Traister Software Engineer ComponentOne LLC www.ComponentOne.com
Thanks for the post Dave Traister, How can I implement this using Sqlcomamnd.Parameters object Regards, Dana
-
Thanks for the post Dave Traister, How can I implement this using Sqlcomamnd.Parameters object Regards, Dana
Hello Dana, Try the following: Dim commandText As String = _ "Select * from Customers Where CustID IN ( @ID);" command.Parameters.Add("@ID", SqlDbType.Int) command.Parameters("@ID").Value = customerID Dim rowsAffected As Integer = command.ExecuteNonQuery() The link below shall give you more information but it does not use the IN operator: http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.parameters.aspx Regards, Dave
Dave Traister Software Engineer ComponentOne LLC www.ComponentOne.com