如何在VB.NET中从两种不同的形式在一个表中插入数据? [英] How to insert data in one table from two different forms in VB.NET?
问题描述
数据库表1有字段,id,cnm,mn,addr,amnt,disc。
现在form1在表1中插入数据(cnm.mn ,addr)
当表单2将其数据插入表1(amnt,disc)时,那时数据将在ms访问中的表单1条目数据中添加。
所以当form1在表1数据库中插入数据时,如id = 1,cnm = abc,mn = 123,addr = xyz,amnt =,disc =。
amnt和表格2中的表格2数据插入之后插入的光盘值。
如id = 1,cnm = abc,mn = 123 ,addr = xyz,amnt = 1000,disc = 100。
我尝试过:
我试图在一个MS Access数据库表中插入两种形式的数据。如果任何人知道它的查询,那么请帮助我。
假设表格1有customer_name,移动,地址和表格2有金额,客户的折扣名称在表格1中添加。
数据库表1有字段,id,cnm,mn,addr,amnt,disc。
现在form1在表1中插入数据(cnm.mn,addr)
当表单2将其数据插入表1(amnt,disc)时,那个时候该数据将在ms访问中的表单1条目数据中添加。
所以当form1在表1数据库中插入数据时,如id = 1,cnm = abc,mn = 123,addr = xyz,amnt =,disc =。
amnt和表格2中的表格2数据插入之后插入的光盘值。
如id = 1,cnm = abc,mn = 123 ,addr = xyz,amnt = 1000,disc = 100.
database table 1 have field like, id,cnm,mn,addr,amnt,disc.
Now form1 insert their data in table 1 (cnm.mn,addr)
and when form 2 inserted their data in table 1(amnt,disc), that time that data will added within form 1 entry data in ms access.
so when form1 insert data in table 1 database, like id =1, cnm=abc, mn=123,addr=xyz,amnt=,disc=.
amnt and disc value inserted after form 2 data insert in table 1 then.
like id =1, cnm=abc, mn=123,addr=xyz,amnt=1000,disc=100.
What I have tried:
I have trying to Insert two forms of data in one table of MS Access Database. If any one known the Queries of it then please help me.
Suppose form 1 have customer_name,Mobile,Address and form 2 have Amount,Discount of the customer which name is added in form 1.
database table 1 have field like, id,cnm,mn,addr,amnt,disc.
Now form1 insert their data in table 1 (cnm.mn,addr)
and when form 2 inserted their data in table 1(amnt,disc), that time that data will added within form 1 entry data in ms access.
so when form1 insert data in table 1 database, like id =1, cnm=abc, mn=123,addr=xyz,amnt=,disc=.
amnt and disc value inserted after form 2 data insert in table 1 then.
like id =1, cnm=abc, mn=123,addr=xyz,amnt=1000,disc=100.
推荐答案
public static class GLOBALVARS
{
public static DataTable dt;
}
if (GLOBALVARS.dt.Columns.Count == 0)
{
GLOBALVARS.dt.Columns.Add("id");
GLOBALVARS.dt.Columns.Add("cnm");
GLOBALVARS.dt.Columns.Add("addr");
GLOBALVARS.dt.Columns.Add("disc");
}
DataRow dr = GLOBALVARS.dt.NewRow();
dr["id"] = 1;
dr["cnm"] = "abc";
dr["addr"] = "xyz";
dr["disc"] = 100;
GLOBALVARS.dt.Rows.Add(dr);
现在将数据存储到表格。
Now store data to table.
这篇关于如何在VB.NET中从两种不同的形式在一个表中插入数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!