本人想实现通过互联网数据的远程传输,具体情况如下:
某管理局下属的几个分散于各地的办公室(都具备宽带上网条件),分别安装Winform的客户端软件,在数十公里外的管理局机房的电脑装有SQL SERVER数据库,作为服务器端。为简化起见各个客户端软件界面上都只有一个Label,一个dataGridView和两个Button,Label的Text值为"12345",点击一个Button可以实现将Label的值("12345")通过宽带网传送到远端服务器并写入SQL SERVER 数据库表中,点击另一个Button可以实现将远端服务器SQL SERVER数据库表中的记录也是通过宽带网传回至客户端并在dataGridview中显示出来。怎样才能实现上述功能,最好有代码供学习,谢谢!
由于本人从未用过Web Service,想请教一下各位在Winform的程序中可不可以调用Web Service?我从网上查到一些Web Service 的应用,其中有这样一个例子:[WebMethod]
public sqlConnection getConn()
{
string sql = "Insert into co_COD (COD_ID, COD_Line, COD_Product, COD_Qty, COD_Price, COD_Amount)";
sql += " Values ('" + this.txtOrderId.Text + "','" + Convert.ToString(lastLine) + "','" + product + "','" + qty.Text + "','0','0'" + ")";
SqlConnection conn = new SqlConnection(Server=***;Database=db_News;Userid=***;password=***;");
return conn;
}如果这样的例子能成立的话,只要把其中的 Server=***; 改成远服务器端电脑的IP,数据库名称、账号、密码改成实际可用的值,岂不是就能实现将Winform程序界面上的一些TextBox控件的当前值通过互联网写入到远程的服务器端数据库中去了吗?请教各位前辈可以实现的了吗?谢谢!
某管理局下属的几个分散于各地的办公室(都具备宽带上网条件),分别安装Winform的客户端软件,在数十公里外的管理局机房的电脑装有SQL SERVER数据库,作为服务器端。为简化起见各个客户端软件界面上都只有一个Label,一个dataGridView和两个Button,Label的Text值为"12345",点击一个Button可以实现将Label的值("12345")通过宽带网传送到远端服务器并写入SQL SERVER 数据库表中,点击另一个Button可以实现将远端服务器SQL SERVER数据库表中的记录也是通过宽带网传回至客户端并在dataGridview中显示出来。怎样才能实现上述功能,最好有代码供学习,谢谢!
由于本人从未用过Web Service,想请教一下各位在Winform的程序中可不可以调用Web Service?我从网上查到一些Web Service 的应用,其中有这样一个例子:[WebMethod]
public sqlConnection getConn()
{
string sql = "Insert into co_COD (COD_ID, COD_Line, COD_Product, COD_Qty, COD_Price, COD_Amount)";
sql += " Values ('" + this.txtOrderId.Text + "','" + Convert.ToString(lastLine) + "','" + product + "','" + qty.Text + "','0','0'" + ")";
SqlConnection conn = new SqlConnection(Server=***;Database=db_News;Userid=***;password=***;");
return conn;
}如果这样的例子能成立的话,只要把其中的 Server=***; 改成远服务器端电脑的IP,数据库名称、账号、密码改成实际可用的值,岂不是就能实现将Winform程序界面上的一些TextBox控件的当前值通过互联网写入到远程的服务器端数据库中去了吗?请教各位前辈可以实现的了吗?谢谢!
解决方案 »
- Excel.Application()无法关闭进程的问题
- TextBox调取数据,设置textbox属性为visible False就不能调取数据了啊!急!
- 怎么实现点击一个按钮,弹出窗体,然后窗体在按钮旁边显示。
- 怎样可以dataGridView的第一列中显示这一行是第几条记录?
- static void Main(string[] args)问题
- 求一存储过程
- C#winform窗体画矩形问题
- create trigger XXX on dbo.tableName after 怎么 用正则表达式 取出 XXX
- VC++.NET 是否可以和VC++一样做硬件的驱动程序?
- 可以让LABEL的颜色透明吗?怎么设置?
- 窗体gridview里数据怎么放dataset里
- 谁有类似把聊天内容格式的字符串处理并显示到dgv的源码?
public bool SaveString(string txtOrderId,string lastline,string product,string qty)
{
string sql = "Insert into co_COD (COD_ID, COD_Line, COD_Product, COD_Qty, COD_Price, COD_Amount)";
sql += " Values ('" + txtOrderId + "','" + lastLine + "','" + product + "','" + qty + "','0','0'" + ")";
SqlConnection conn = new SqlConnection(Server=***;Database=db_News;Userid=***;password=***;");
SqlCommand com = new SqlCommnad(conn);
com.CommandText = sql;
com.ExecuteNonQuery();
return true;
}
不过还有点疑问:
如果以下的代码干脆连[WebMethod]也省略掉,就当是一个一般的SQL插入记录语句,放在Winform程序中用,只是数据库连接字符串用上远程电脑的IP及库表名、账号、密码,好像也应可以实现嘛,请前辈明示,谢谢。
public bool SaveString(string txtOrderId,string lastline,string product,string qty)
{
string sql = "Insert into co_COD (COD_ID, COD_Line, COD_Product, COD_Qty, COD_Price, COD_Amount)";
sql += " Values ('" + txtOrderId + "','" + lastLine + "','" + product + "','" + qty + "','0','0'" + ")";
SqlConnection conn = new SqlConnection(Server=***;Database=db_News;Userid=***;password=***;");
SqlCommand com = new SqlCommnad(conn);
com.CommandText = sql;
com.ExecuteNonQuery();
return true;
}
public bool SaveString(string txtOrderId,string lastline,string product,string qty)
{
string sql = "Insert into co_COD (COD_ID, COD_Line, COD_Product, COD_Qty, COD_Price, COD_Amount)";
sql += " Values ('" + txtOrderId + "','" + lastLine + "','" + product + "','" + qty + "','0','0'" + ")";
SqlConnection conn = new SqlConnection(Server=***;Database=db_News;Userid=***;password=***;");
SqlCommand com = new SqlCommnad(conn);
com.CommandText = sql;
com.ExecuteNonQuery();
return true;
}
假如某天 这个方法的的内部需要有些变化 你就需要更新所有客户端的Winform程序了 而采用Webservice的话 仅仅需更新服务器端的这个方法 就ok了