从对象类型System.Windows.Forms.ControlBindingsCollection映射错误 [英] Mapping Error from object type System.Windows.Forms.ControlBindingsCollection

查看:59
本文介绍了从对象类型System.Windows.Forms.ControlBindingsCollection映射错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows应用程序中,我使用monthCalendar从数据库中搜索数据。如果我点击日期/星期/月,它应该在网格视图中显示数据,但在运行时它会抛出如下所示的错误。但是当我在

In windows application I have used monthCalendar to search data from database. If I click on date/week/month it should show the data in the Grid View, but at runtime it throws me an error shown below. But when i put a comment at

Quote:

da.Fill(ds,Interviews);

da.Fill(ds, "Interviews");

中发表评论时,会显示空的gridview。



错误

the empty gridview is displayed.

ERROR:

Quote:

从对象类型System.Windows.Forms.ControlBindingsCollection到已知的托管提供者本机类型没有映射。

No mapping exists from object type System.Windows.Forms.ControlBindingsCollection to a known managed provider native type.





请检查代码你的参考和请帮助我。





Please check the code for your reference & please assist me.

private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e)
        {
            
                DataTable dt = new DataTable();
                DateTime mdate = monthCalendar1.SelectionRange.Start.Date;
                DateTime start = monthCalendar1.SelectionStart;
                DateTime end = monthCalendar1.SelectionEnd;
                SqlCommand cmd = new SqlCommand("select * from Interviews where intvwdate=" + Convert.ToDateTime(monthCalendar1.SelectionStart), con);
                cmd.Parameters.AddWithValue("@intvwdate", monthCalendar1.DataBindings);
                SqlDataAdapter da = new SqlDataAdapter(cmd);

                da.Fill(ds, "Interviews");
                dataGridView1.Show();
                dataGridView1.DataSource = ds.Tables["Interviews"];
            

        }

推荐答案

我认为错误就在这句话中



I think the error is in this sentence

SqlCommand cmd = new SqlCommand("select * from Interviews where intvwdate=" + Convert.ToDateTime(monthCalendar1.SelectionStart), con);

cmd.Parameters.AddWithValue("@intvwdate", monthCalendar1.DataBindings);
SqlDataAdapter da = new SqlDataAdapter(cmd);





必须是。





It must be.

SqlCommand cmd = new SqlCommand("select * from Interviews where intvwdate=@intvwdate", con);

cmd.Parameters.AddWithValue("@intvwdate", Convert.ToDateTime(monthCalendar1.SelectionStart));
SqlDataAdapter da = new SqlDataAdapter(cmd);


这篇关于从对象类型System.Windows.Forms.ControlBindingsCollection映射错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆