try
{
//创建一个SqlConnection对象
string strCon = "Initial Catalog='数据库名称';Server='远程IP地址,1433';User ID='登录用户名';Password='登录用户密码';Persist Security Info=True";
SqlConnection myConn = new SqlConnection ( strCon ) ;
string strCom = " insert into ……" ;
//创建一个 DataSet对象
myDataSet = new DataSet ( ) ;
myConn.Open ( ) ;
SqlDataAdapter myCommand = new SqlDataAdapter ( strCom , myConn ) ;
myCommand.Fill ( myDataSet , "数据表名称" ) ;
myConn.Close ( ) ;
//关闭连接
statusBar1.Text="远程SQL数据库连接成功";
}
catch ( Exception ex2 )
{
statusBar1.Text="连接远程SQL数据库失败";
MessageBox.Show ( "连接远程SQL数据库发生错误:" + ex2.ToString ( ) , "错误!" ) ;
}
new sqlcommand(insert into ...,new sqlconnection(connectionstring)).executenonquery.
不懂hi我。
建一个表 弄到表里面就ok了