首页 新闻 会员 周边

TableAdapter insert 无效

0
悬赏园豆:10 [已解决问题] 解决于 2008-02-20 20:35
使用设计器编程数据集,再查询生成器,再执行查询,输入数据后,就可以录入到数据文件中。 <BR><BR>但是在编程中却不能实现。比如 <BR><BR>s_day &nbsp; = &nbsp; Convert.ToInt32(Convert.ToDateTime(dateTimePicker1.Value.ToString()).Day.ToString()); <BR>s_month &nbsp; = &nbsp; Convert.ToInt32(Convert.ToDateTime(dateTimePicker1.Value.ToString()).Month.ToString()); <BR>s_year &nbsp; = &nbsp; Convert.ToInt32(Convert.ToDateTime(dateTimePicker1.Value.ToString()).Year.ToString()); <BR>s_money &nbsp; = &nbsp; Convert.ToSingle(textBox2.Text); <BR>s_name &nbsp; = &nbsp; textBox1.Text; <BR>s_infromation &nbsp; = &nbsp; textBox4.Text; <BR>s_user &nbsp; = &nbsp; textBox3.Text; <BR>Database1DataSetTableAdapters.shang_money_moneyTableAdapter &nbsp; insert_ad &nbsp; = &nbsp; new &nbsp; WindowsApplication1.Database1DataSetTableAdapters.shang_money_moneyTableAdapter(); <BR>try <BR>{ <BR>insert_ad.Insert(s_money, &nbsp; s_year, &nbsp; s_month, &nbsp; s_day, &nbsp; s_user, &nbsp; s_name, &nbsp; s_infromation); <BR>} <BR>catch &nbsp; (Exception &nbsp; ee) <BR>{ <BR>textBox4.Text &nbsp; = &nbsp; ee.ToString(); <BR>} <BR><BR>可以运行,但是根本就无法插入数据!! &nbsp; 但是 &nbsp; 单独的执行这个语句的时候是完全可以的 <BR>请求打人帮忙解决了
guojing的主页 guojing | 初学一级 | 园豆:145
提问于:2008-02-01 16:48
< >
分享
最佳答案
0
楼主,试试改用 Command或者 将数据包装到Row 中在试试。 确切说,我没有这么用过。Insert方法是内部生成的,主要也是给Update用的,不过可能还有其他部分。没有研究过 不过,我还用过一个是,将这个SQL查询写到DA里,就是添加查询,然后会输入一个方法名。我是这么一直用这个来处理DAL的。楼主可以试试
G yc {Son of VB.NET} | 老鸟四级 |园豆:2006 | 2008-02-02 23:49
其他回答(1)
0
>> 可以运行,但是根本就无法插入数据!! 但是 单独的执行这个语句的时候是完全可以的 看得一头雾水,什么意思? 可以执行,又无法插入数据?请描述的详细一些。
Colin Han | 园豆:3041 (老鸟四级) | 2008-02-03 13:36
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册