PL很好,有人在此更新按钮代码中有问题(错误消息:位置-1没有行) [英] PL nice someone i have aproblem in this update button code (erro message: there is no row at postion -1)

查看:58
本文介绍了PL很好,有人在此更新按钮代码中有问题(错误消息:位置-1没有行)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新鳕鱼为

update cod is

int x;
            con = new SqlConnection(str);
            da = new SqlDataAdapter();
            da.UpdateCommand = new SqlCommand("UPDATE customers SET name=@name,address=@address,insurance_cost=@insurance_cost,record_date=@record_date WHERE code_customer=@code_customer", con);
            da.UpdateCommand.Parameters.Add("@name", SqlDbType.NVarChar).Value = textBox1.Text;
            da.UpdateCommand.Parameters.Add("@address", SqlDbType.NVarChar).Value = textBox2.Text;
            da.UpdateCommand.Parameters.Add("@insurance_cost", SqlDbType.Money).Value = textBox3.Text;
            da.UpdateCommand.Parameters.Add("@record_date", SqlDbType.DateTime).Value = dateTimePicker1.Value;
            da.UpdateCommand.Parameters.Add("@code_customer", SqlDbType.BigInt).Value = dset.Tables["customers"].Rows[bs.Position][0];
            con.Open();
            x = da.UpdateCommand.ExecuteNonQuery();
            con.Close();
            if (x >= 1)
                MessageBox.Show("Record(s)has been updated");



如果(x> = 1)
MessageBox.Show(记录已更新");

如果(x> = 1)
MessageBox.Show(记录已更新");



if (x >= 1)
MessageBox.Show("Record(s)has been updated");

if (x >= 1)
MessageBox.Show("Record(s)has been updated");

推荐答案

da.UpdateCommand.Parameters.Add("@code_customer", SqlDbType.BigInt).Value = dset.Tables["customers"].Rows[bs.Position][0];



我认为问题出在



i think the problem is in

Rows[bs.Position]



只是检查其是否有任何行.一次调试.
我认为其余的事情都很好.



just chek its getting any row No or not. debug at once.
i think rest of the thing are fine.


这篇关于PL很好,有人在此更新按钮代码中有问题(错误消息:位置-1没有行)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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