I have a CSV file of products I am parsing to create a SQL file and eventually run on the database to add the products.
I am creating my query like this:
Dim sql As String = "INSERT INTO ""APP"".""PRODUCTS"" (ID,REFERENCE,CODE,CODETYPE,NAME,PRICEBUY,PRICESELL,CATEGORY,TAXCAT,ATTRIBUTESET_ID,STOCKCOST,STOCKVOLUME,IMAGE,ISCOM,ISSCALE,ISKITCHEN,ATTRIBUTES) VALUES (@ID,@REFERENCE,@CODE,@CODETYPE,@NAME,@PRICEBUY,@PRICESELL,@CATEGORY,@TAXCAT,@ATTRIBUTESET_ID,@STOCKCOST,@STOCKVOLUME,@IMAGE,@ISCOM,@ISSCALE,@ISKITCHEN,@ATTRIBUTES)"
Dim cmd As New SqlCommand(sql)
cmd.Parameters.AddWithValue("@ID", ID)
cmd.Parameters.AddWithValue("@REFERENCE", REFERENCE)
cmd.Parameters.AddWithValue("@CODE", CODE)
cmd.Parameters.AddWithValue("@CODETYPE", CODETYPE)
cmd.Parameters.AddWithValue("@NAME", NAME)
cmd.Parameters.AddWithValue("@PRICEBUY", PRICEBUY)
cmd.Parameters.AddWithValue("@PRICESELL", PRICESELL)
cmd.Parameters.AddWithValue("@CATEGORY", CATEGORY)
cmd.Parameters.AddWithValue("@TAXCAT", TAXCAT)
cmd.Parameters.AddWithValue("@ATTRIBUTESET_ID", ATTRIBUTESET_ID)
cmd.Parameters.AddWithValue("@STOCKCOST", STOCKCOST)
cmd.Parameters.AddWithValue("@STOCKVOLUME", STOCKVOLUME)
cmd.Parameters.AddWithValue("@IMAGE", IMAGE)
cmd.Parameters.AddWithValue("@ISCOM", ISCOM)
cmd.Parameters.AddWithValue("@ISSCALE", ISSCALE)
cmd.Parameters.AddWithValue("@ISKITCHEN", ISKITCHEN_NEW)
cmd.Parameters.AddWithValue("@ATTRIBUTES", ATTRIBUTES)
However I do not wish to execute them via .NET, how can I simply export the queries (with the parameters replaced) to a text box, one line per query. (this code is running in a loop and this is for one product in that loop)
I tried cmd.CommandText but it just lists the SQL query with @ID instead of the actual value of the ID variable.
Thanks guys