uno中的参数问题...我想它应该自动选择uno .... [英] parameter problem in uno...iwant that it should select uno....automatically

查看:57
本文介绍了uno中的参数问题...我想它应该自动选择uno ....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的数据库包含一个

用户表,包&

包详细信息表.....在用户中

表有uno(用户号码)主键...&

uno也出现在

包中,这是外国的。 key



我在做项目。在c#windows窗体上



package.cs

btn save(....





cbpno.Text =或者txtchlnno.Text =然后

MsgBox(填充字段..,MsgBoxStyle.Information,错误)





如果txtcdtdys.Text.tocompare。

> 7或txtcdtdys.Text.to比较< 1然后

MsgBox(Credit Days sholud在1-7范围内)

txtcdtdys.Clear()

txtcdtdys。焦点()

退出Sub

结束如果

如果txtchlnno.TextLength< 5那么

如果action = 添加然后

Dim com作为新的SqlCommand

com.CommandText =插入包值(@ PNo,@ PDate,@ Challan_No,@ Challan_Date,@ Credit_Days, @ Due_Date,@ Transport,@ Vat,@ CNo,@ Uno,@ Deleted)

com.Parameters.AddWithValue(@ PNo,cbpno.T分机)

com.Parameters.AddWithValue(@ PDate,txtpckgdt.Text)

com.Parameters.AddWithValue(@ Challan_No,txtchlnno.Text)

com.Parameters.AddWithValue(@ Challan_Date,txtclndte.Text)

com.Parameters.AddWithValue(@ Credit_Days,txtcdtdys.Text)

com.Parameters.AddWithValue(@ Due_Date,txtduedte.Text)

com.Parameters.AddWithValue(@ Transport,cbtransport.Text)

com。 Parameters.AddWithValue(@ Vat,txtvat.Text)

com.Parameters.AddWithValue(@ CNo,txtcustno.Text)

com.Parameters.AddWithValue( @UNo,字符串)

com.Parameters.AddWithValue(@ Deleted,0)

com.Connection = con

尝试

con.Open()

com.ExecuteNonQuery()

MessageBox.Show(保存记录)

my database contain a
user table,package&
package detail table .....in user
table there is uno(User no) primary key...&
uno is also present in
package which is foreign. key

i am doing project. on c# windows form

package.cs
btn save(....


cbpno.Text = "" Or txtchlnno.Text = "" Then
MsgBox("Fill the Field..", MsgBoxStyle.Information, "error")


If txtcdtdys.Text.tocompare.
> 7 Or txtcdtdys.Text.to compare< 1 Then
MsgBox("Credit Days sholud be in the range 1-7")
txtcdtdys.Clear()
txtcdtdys.Focus()
Exit Sub
End If
If txtchlnno.TextLength < 5 Then
If action = "Add" Then
Dim com As New SqlCommand
com.CommandText = "insert into Package values(@PNo,@PDate,@Challan_No,@Challan_Date,@Credit_Days,@Due_Date,@Transport,@Vat,@CNo,@Uno,@Deleted)"
com.Parameters.AddWithValue("@PNo", cbpno.Text)
com.Parameters.AddWithValue("@PDate", txtpckgdt.Text)
com.Parameters.AddWithValue("@Challan_No", txtchlnno.Text)
com.Parameters.AddWithValue("@Challan_Date", txtclndte.Text)
com.Parameters.AddWithValue("@Credit_Days", txtcdtdys.Text)
com.Parameters.AddWithValue("@Due_Date", txtduedte.Text)
com.Parameters.AddWithValue("@Transport", cbtransport.Text)
com.Parameters.AddWithValue("@Vat", txtvat.Text)
com.Parameters.AddWithValue("@CNo", txtcustno.Text)
com.Parameters.AddWithValue("@UNo", string)
com.Parameters.AddWithValue("@Deleted", "0")
com.Connection = con
Try
con.Open()
com.ExecuteNonQuery()
MessageBox.Show("Record saved")

推荐答案

com.Parameters.AddWithValue("@UNo", string)

这里的第二个参数是无效。你应该提供一些字符串值,而不是字符串关键字本身。



据我所知,用户主键 Uno 有一个与User相关的列。

因此,在 Package 表中插入记录时,你必须提供 Uno ,无法自动插入。如果您不插入它,它将变为 null

Here 2nd parameter is invalid. You should provide some string value, not string keyword itself.

As far as I understand, User Tables Primary Key is Uno and Package have one column related to User.
So, while inserting record in Package Table, you have to provide the Uno, it can't be automatically inserted. If you will not insert that, it would become null.


这篇关于uno中的参数问题...我想它应该自动选择uno ....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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