0
SQL代码我想要使用一个标量函数次想在asp.net代码使用taht但我geeting错误“不正确的语法近F1”“函数名称” F
create function f1(@pay float)
returns float
as
begin
return(@pay*8*10)
end
C#代码
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["abc"]);
float a;
SqlCommand cmd = new SqlCommand("dbo.f1",con);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@pay",TextBox1.Text);
//cmd.Parameters.AddWithValue("@uname", TextBox2.Text);
con.Open();
a = (float)(cmd.ExecuteScalar());
TextBox2.Text = System.Convert.ToString(a);
con.Close();
}
}
为什么'COUNT(*)'? – 2012-08-09 14:18:51
类似于那样,你可以使用“Select dbo.f1” – SuganR 2012-08-09 14:21:10
SuganR Plz解释了我从textbox1.text中获取的值是如何在我的例子“cmd.Parameters.AddWithValue(”@ pay“,TextBox1.Text);”将达到函数f1作为参数。由于函数f1需要参数.. – Rahul 2012-08-10 19:16:24