sql代码
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();
}
}