edit still recieving type mismatch error but updated code with help from comments -updated code shown below
I am new to ASP and VBScript. I am trying to insert post data into a SQL database, however, I want to ensure the query is sterilized so I am trying to use a parameterized query. When I execute the query I get this error.
Microsoft VBScript runtime error '800a000d'
Type mismatch
my code looks like this
Set conn = Server.CreateObject("ADODB.Connection")
conn.Mode = 3
conn.open "Provider=SQLOLEDB;Data Source=xxx.xxx.xxx.xxx,xxxx;
database=db_example;uid=user;pwd=password;"
Dim oCmd
set oCmd= Server.CreateObject("ADODB.Command")
Dim sSQL
sSQL = "INSERT INTO tbl_Application (Expenses, Name, Why) VALUES (?, ?, ?);"
oCmd.CommandText = sSQL
oCmd.ActiveConnection= conn
Dim uPar
uPar = oCmd.CreateParameter("Expenses",200,1,255,session("Expenses"))
oCmd.Parameters.Append(uPar)
Dim vPar
vPar = oCmd.CreateParameter("Name",200,1,255,session("Name"))
oCmd.Parameters.Append(vPar)
Dim wPar
wPar = oCmd.CreateParameter("Why",200,1,255,session("Why"))
oCmd.Parameters.Append(wPar)
Dim oRS
oRS = oCmd.Execute()
I have tried typing the data as a varchar and a char. Please let me know if you have a fix for my problem. Also, I am intending to insert more than three pieces of data on the site - is there a better way than going through and making a parameter manually for each column?
Dimfor declaring variables using vbscript. msdn.microsoft.com/en-us/library/t7zd6etz%28v=vs.84%29.aspx.varis used in jscriptDim xyzand then on second linexyz = "something"Dim xyz : xyz = "something"createparametermethod, notice the use ofsetmsdn.microsoft.com/en-us/library/windows/desktop/…