在我的计划中,我有这个声明......
ct = String.Format(@"select [Movie Selector] from WSTMDS3
natural prediction join
(select
'{0}'as[Age],
'{1}'as[Education Level],
'{2}'as[Gender],
'{3}'as[Home Ownership],
'{4}'as[Internet Connection],
'{5}'as[Marital Status]
)as MovieSelector",
TextBox1.Text,
DropDownList1.SelectedValue,
DropDownList2.SelectedValue,
DropDownList3.SelectedValue,
DropDownList4.SelectedValue,
DropDownList5.SelectedValue)
;
Run Code Online (Sandbox Code Playgroud)
但是在DropDown list1"教育水平"中,我有一些像这个硕士学位的价值,我在这个陈述中如何使用单引号.
谢谢
Mar*_*ers 10
您不应该使用string.Format构建查询.您应该使用参数化查询.
adomdCommand.CommandText = "SELECT ... @P1 ...";
adomdCommand.Parameters.Add(new AdomdParameter("P1", TextBox1.Text));
// etc..
Run Code Online (Sandbox Code Playgroud)
有关