我想更改存储过程的代码:
string sql6 = string.Format("SELECT * from t_vsubmenu where mainid=" + Convert.ToInt32(ds4.Tables[0].Rows[i]["fid"].ToString()));
SqlDataAdapter da6 = new SqlDataAdapter(sql6, con);
DataSet ds6 = new DataSet();
da6.Fill(ds6, "t_vsubmenu");
DataTable db6 = ds6.Tables["t_vsubmenu"];
我现在不怎么做?我的问题是如何将fid代码发送到存储过程?
例如,我的存储过程是:
create PROCEDURE [dbo].[select_t_vsubmenu]
作为
begin
select * from t_vsubmenu
end
答案 0 :(得分:0)
首先,您可以向存储过程添加参数:
SqlCommand cmd = new SqlCommand("select_vsubmenu_input_mainid", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@mainid", SqlDbType.Int);
cmd.Parameters["@mainid"].Value = Convert.ToInt32(ds4.Tables[0].Rows[i]["fid"].ToString());
cmd.Open();
DataTable db6 = new DataTable();
SqlDataAdapter da6 = new SqlDataAdapter();
da6.SelectCommand = cmd;
da6.Fill(db6);
然后,使用SqlCommand类调用您的过程:
subset
要获得完整的示例,请查看SqlCommand类帮助。
https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand(v=vs.110).aspx
答案 1 :(得分:0)
function addSearchControl(map) {
$('#searchPanel').hide();
$('#searchControl').click(function() {$('#searchPanel').toggle(500);});
$('#search').get(0).index = 1;
map.controls[google.maps.ControlPosition.TOP_RIGHT].push($('#search').get(0));
$('#search').css('right', 'initial');
}