Pages

Wednesday, September 18, 2013

Query to Create Dynamically com.Parameters.Add - SQL




Select +'com.Parameters.AddWithValue("@'+COLUMN_NAME+' ", dt_results.Rows[i]["'+COLUMN_NAME+'"]); ' from INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='YourTableName'


This Gives Output :

                    com.Parameters.AddWithValue("@ItemId", dt_results.Rows[i]["ItemId"]);
                    com.Parameters.AddWithValue("@GlobalId", dt_results.Rows[i]["GlobalId"]);
                    com.Parameters.AddWithValue("@ProductId", dt_results.Rows[i]["ProductId"]);
                    com.Parameters.AddWithValue("@CategoryId", dt_results.Rows[i]["CategoryId"]);
                    com.Parameters.AddWithValue("@CategoryName", dt_results.Rows[i]["CategoryName"]);
                    com.Parameters.AddWithValue("@Location", dt_results.Rows[i]["Location"]);
                    com.Parameters.AddWithValue("@PostalCode", dt_results.Rows[i]["PostalCode"]);
                    com.Parameters.AddWithValue("@Title", dt_results.Rows[i]["Title"]);
                    com.Parameters.AddWithValue("@Price", dt_results.Rows[i]["Price"]);
                    com.Parameters.AddWithValue("@SellingState", dt_results.Rows[i]["SellingState"]);
                    com.Parameters.AddWithValue("@TimeLeft", dt_results.Rows[i]["TimeLeft"]);
                    com.Parameters.AddWithValue("@ShippingType", dt_results.Rows[i]["ShippingType"]);
                    com.Parameters.AddWithValue("@Currency", dt_results.Rows[i]["Currency"]);
                    com.Parameters.AddWithValue("@ShipToLocations", dt_results.Rows[i]["ShipToLocations"]);
                    com.Parameters.AddWithValue("@HandlingTime", dt_results.Rows[i]["HandlingTime"]);


No comments:

Post a Comment