Click here to Skip to main content
15,883,799 members
Articles / Programming Languages / SQL

store SQL query in database when I use parameter

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
1 Oct 2012CPOL 4K  
can anyone help me how I can store SQL query (statement as log) in database when I use parameter to execute a query?...My prefer language = vb.net for example : sql = "insert into model (name, age, date_of_confinement,type_of_sickness, type_of_IVfluid, number_of_bottles, drop_rate)" &...

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

Please Sign up or sign in to vote.
1 Oct 2012OriginalGriff
Try:Using con As New SqlConnection(strConnect) con.Open() Using com As New SqlCommand("INSERT INTO myTable (myColumn1, myColumn2) VALUES (@C1, @C2)", con) com.Parameters.AddWithValue("@C1", myValueForColumn1) com.Parameters.AddWithValue("@C2",...
Please Sign up or sign in to vote.
3 Oct 2012Raimis9
Try this way:Dim sql As String = "INSERT INTO myTable (myColumn1, myColumn2) VALUES (@C1, @C2)" Dim sql_to_log As String = sql sql_to_log = sql_to_log.Replace("@C1", myValueForColumn1.tostring) sql_to_log = sql_to_log.Replace("@C2", myValueForColumn2.tostring)Save...
Please Sign up or sign in to vote.
2 Oct 2012sali22
there is no other solution !!?let me explain again,, I want to display the query string after execution when parameters have been used ,I hope you will get what do i mean

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Comments and Discussions