日期:2014-05-18 浏览次数:20822 次
db = new SqlConnection(ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString); db.Open(); string SQLStatement = "EXEC [BasicSearch] @totalResults = '100',@miles =N'100'"; SqlDataAdapter SQLDataAdapter = new SqlDataAdapter(SQLStatement, db); DataTable dtResult = new DataTable(); SQLDataAdapter.Fill(dtResult); SQLDataAdapter.Dispose(); ListView1.DataSource = dtResult; db.Close();
------解决方案--------------------
DataSet Serilize成Byte[]通过Socket 发送
remoting
通过XML实现数据传输
------解决方案--------------------
把整个datatable序列化后发送
private void sendData(string str)
{
SqlDataAdapter da = new SqlDataAdapter(str,conn);
DataSet ds = new DataSet();
da.Fill(ds,"mytable");
BinaryFormatter formatter = new BinaryFormatter();
NetworkStream stream = new NetworkStream(currentSocket);
formatter.Serialize(stream,ds);
stream.Flush();
stream.Close();
}