我应该使用什么代码? C#.Net + Mysql Wb, [英] What Code Should I Use? C#.Net + Mysql Wb,

查看:79
本文介绍了我应该使用什么代码? C#.Net + Mysql Wb,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我想弄清楚,我应该用什么代码将数据库B中的值添加到数据库A,假设我的库存中有一个3的值(数据库B)和

库存中的4值(数据库A),我想将库存(数据库B)添加到库存(数据库A),有谁想帮我?





试试

{





string modConnection =datasource = localhost; port = 3306; username = root; password = 1234;

string modQuery =UPDATE testinglang.maintest SET Id =' + this.rIdTxt.Text +',Items ='+ this.rItemsTxt.Text +',Stock ='+(rStockTxt.Text + ?????????????)+'其中Id ='+ this.rIdTxt.Text +';;



MySqlConnection modData = new MySqlConnection(modConnection);

MySqlCommand modCommandData = new MySqlCommand(modQuery,modData);

MySqlDataReader MyReader;



modData.Open();

MyReader = modCommandData.ExecuteReader();

MessageBox.Show(Registered Data ..);



this.Hide( );

wh ile(MyReader.Read())

{



}



}

catch(Exception ex)

{

MessageBox.Show(ex.Message);

}

hello guys, i'm trying to figure out, what code should i use to add a value from database B to database A, lets say i had a value of "3" in stock(database B) and
value of "4" in Stock(database A), and i want to add the value stock(database B) to stock(database A), anyone would like to help me?


try
{


string modConnection = "datasource=localhost;port=3306;username=root;password=1234";
string modQuery = "UPDATE testinglang.maintest SET Id = '" + this.rIdTxt.Text + "',Items = '" + this.rItemsTxt.Text + "',Stock = '" + (rStockTxt.Text+?????????????) + "' Where Id = '" + this.rIdTxt.Text + "';";

MySqlConnection modData = new MySqlConnection(modConnection);
MySqlCommand modCommandData = new MySqlCommand(modQuery, modData);
MySqlDataReader MyReader;

modData.Open();
MyReader = modCommandData.ExecuteReader();
MessageBox.Show("Registered Data..");

this.Hide();
while (MyReader.Read())
{

}

}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}

推荐答案

C#ADO.Net代码应该满足您的要求。如果你不需要任何转换,请阅读DataTable表单DB1并在DB2中进行批量复制。



希望这能让你抬起头来。
C# ADO.Net code should suffice your requirement. Read DataTable form DB1 and have it bulk copy in DB2 if you dont need any transformations.

Hope this gives you heads up.


这篇关于我应该使用什么代码? C#.Net + Mysql Wb,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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