本文介绍了试图将自动编号从一个表复制到下一个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

到目前为止,我已经尝试了这个的微软版本,并且丢失了表格

LOl

所以我试着用这种方式写入两个携带autoid的表

但到目前为止我无法获得自动编号并将其放在另一张表中。


感谢大家提供任何帮助

也许我试着以愚蠢的方式做到这一点但它看起来像我这样

应该工作

可能不是这样:)


哦,人和成员的传递值都在sql字符串中

至少我知道怎么检查

sparks


==============================

tblperson创建autoid PersonID

但是当我尝试在tblmember中创建它时,我在第一个

ExecuteNonQuery上出现错误。


========= =====================

public void SavePerson(此人,会员)

{

Connection.Open(); // ToShortDateString()

尝试

{

String sqlString =" insert into

tblPerson(ContractNumber,姓名,地址,电话号码,条形码)" +

" values(" +

person.getContractNumber()+",''" +

person.getName()+"'',''" +

person.getAddress()+"'',''" +

person.getPhoneNum()+"'',''" +

person.getBarcodeNum()+"'')" ;;

OleDbCommand command = new

OleDbCommand(sqlString,Connection);


command.ExecuteNonQuery();

OleDbCommand cmd = new

OleDbCommand(" SELECT @@ IDENTITY",Connection);

int nId =(int)cmd.ExecuteScalar();

- -------------------------------------------------- -------------------------------------------------- ---

String sqlStr =" insert into tblMember(personID,MonthlyFee,paidup)" +
" values(" + nId +

member.getFee()+"," + member.getMemValidation()+")" ;;

OleDbCommand comma = new OleDbCommand(sqlStr,Connection);


command.ExecuteNonQuery();

Connection.Close();

}

终于

{

如果(连接!= null)

{

if(Connection.State ==

ConnectionState.Open)

Connection.Close();

}

}

解决方案







So far I have tried the microsoft version of this, and lost the table
LOl
so I tried this way to write to two tables carrying over the autoid
but so far I can not get the autonumber and put it in the other table.

thanks big time for any help
maybe I tried to do it the dumb way but it looks to me like this
should work
probably not :)

oh the passed values for person and member are are in the sql strings
at least I knew how to check that
sparks

==============================
the tblperson creates the autoid PersonID
but when I try to create it in tblmember I get an error on the first
ExecuteNonQuery.

==============================

public void SavePerson (Person person,Member member)
{
Connection.Open (); //ToShortDateString()
try
{
String sqlString = "insert into
tblPerson (ContractNumber,Name, Address, PhoneNumber, barcode)"+
"values (" +
person.getContractNumber() + ",''" +
person.getName() +"'',''" +
person.getAddress() +"'',''" +
person.getPhoneNum() +"'',''" +
person.getBarcodeNum() + "'')";
OleDbCommand command = new
OleDbCommand (sqlString, Connection);

command.ExecuteNonQuery();
OleDbCommand cmd = new
OleDbCommand("SELECT @@IDENTITY", Connection);
int nId = (int)cmd.ExecuteScalar();
---------------------------------------------------------------------------------------------------------
String sqlStr = "insert into tblMember (personID,MonthlyFee,paidup)"+
"values (" + nId +
member.getFee() + "," + member.getMemValidation() + ")";
OleDbCommand comma = new OleDbCommand (sqlStr, Connection);

command.ExecuteNonQuery();
Connection.Close();
}
finally
{
if (Connection!= null)
{
if (Connection.State ==
ConnectionState.Open)
Connection.Close();
}
}

解决方案







这篇关于试图将自动编号从一个表复制到下一个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 17:55