您好,我收到此错误,似乎无法弄清楚可能出了什么问题。我认为这可能与提供者名称有关,但它会给我带来错误。
错误“ASP.default_aspx”不包含“SqlDataSource1_Selecting”的定义,并且找不到接受“ASP.default_aspx”类型的第一个参数的扩展方法“SqlDataSource1_Selecting”(您是否缺少 using 指令或程序集引用?)
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"
SelectCommand="SELECT * FROM [John_IEP_Crossing_Dock_Shipment]"
onselecting="SqlDataSource1_Selecting">
</asp:SqlDataSource>
这就是数据源的样子。我的网络配置看起来像这样。
<connectionStrings>
<add name="ConnectionString" connectionString="Provider=SQLOLEDB;Data Source=mydatasource;Persist Security Info=True;Password=mypass;User ID=myuser;Initial Catalog=mycatalog"
providerName="System.Data.OleDb" />
</connectionStrings>
我的连接管理器看起来像这样
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
con.Open();
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("insert into tbl values('" + generateidtxt.Text + "','" + hawbtxt.Text + "','" + invrefpotxt.Text + "','" + hppartnumtxt.Text + "','" + iecpartnumtxt.Text + "','" + qtytxt.Text + "','" + bulkstxt.Text + "','" + boxplttxt.Text + "','" + rcvddatetxt.Text + "','" + statustxt.Text + "','" + carriertxt.Text + "','" + shippertxt.Text + "')", con);
cmd.ExecuteNonQuery();
con.Close();
Label1.Visible = true;
Label1.Text = "Your DATA stored Successfully!";
hawbtxt.Text = "";
invrefpotxt.Text = "";
hppartnumtxt.Text = "";
iecpartnumtxt.Text = "";
qtytxt.Text = "";
bulkstxt.Text = "";
boxplttxt.Text = "";
rcvddatetxt.Text = "";
statustxt.Text = "";
carriertxt.Text = "";
shippertxt.Text = "";
}