调用bcp,网上说可以远程,试了下貌似不行,哎,咋办。
2008-10-21 02:01
295 查看
protected void btnimport_Click(object sender, EventArgs e)
{
string filepath = FileUpload1.PostedFile.FileName;
string path=filepath.Remove(filepath.LastIndexOf("//"));
string filename=FileUpload1.FileName.Trim();
bool checkspace = path.Contains(" ");
string extName = "";
extName = filepath.Substring(filepath.LastIndexOf(".") + 1);//获得文件的扩展名
if (extName == "txt")
{
string BcpExec = "";
string BcpExec1 = "";
if (checkspace)
{
BcpExec = "subst w: /"" + path.Trim() + "/"";
BcpExec1 = @"bcp xdcx..BadLoan in w:/" + filename + " ";
}
else
{
BcpExec = "cd";
BcpExec1 = @"bcp xdcx..BadLoan in "+filepath+"";
}
//BcpExec += ds.Tables[0].Rows[i]["path"].ToString();
BcpExec1 += " -c -t , -S10.0.74.15 -Usa -P1234";//组合bcp命令
string msg=ExeCommand(BcpExec, BcpExec1);//执行bcp命令并显示操作结果
private string ExeCommand(string commandText, string commandText1)
{
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
string strOutput = null;
try
{
p.Start();
p.StandardInput.WriteLine(commandText);
p.StandardInput.WriteLine(commandText1);
p.StandardInput.WriteLine("exit");
strOutput = p.StandardOutput.ReadToEnd();
p.WaitForExit();
p.Close();
}
catch (Exception e)
{
strOutput = e.Message;
}
return strOutput;
}
{
string filepath = FileUpload1.PostedFile.FileName;
string path=filepath.Remove(filepath.LastIndexOf("//"));
string filename=FileUpload1.FileName.Trim();
bool checkspace = path.Contains(" ");
string extName = "";
extName = filepath.Substring(filepath.LastIndexOf(".") + 1);//获得文件的扩展名
if (extName == "txt")
{
string BcpExec = "";
string BcpExec1 = "";
if (checkspace)
{
BcpExec = "subst w: /"" + path.Trim() + "/"";
BcpExec1 = @"bcp xdcx..BadLoan in w:/" + filename + " ";
}
else
{
BcpExec = "cd";
BcpExec1 = @"bcp xdcx..BadLoan in "+filepath+"";
}
//BcpExec += ds.Tables[0].Rows[i]["path"].ToString();
BcpExec1 += " -c -t , -S10.0.74.15 -Usa -P1234";//组合bcp命令
string msg=ExeCommand(BcpExec, BcpExec1);//执行bcp命令并显示操作结果
private string ExeCommand(string commandText, string commandText1)
{
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
string strOutput = null;
try
{
p.Start();
p.StandardInput.WriteLine(commandText);
p.StandardInput.WriteLine(commandText1);
p.StandardInput.WriteLine("exit");
strOutput = p.StandardOutput.ReadToEnd();
p.WaitForExit();
p.Close();
}
catch (Exception e)
{
strOutput = e.Message;
}
return strOutput;
}
相关文章推荐
- 本地可以但远程不行
- 在远程调用别人接口的时候,传输参数一般都是String类型的字符串,改字符串可以是json格式的,也可以是xml格式的,那么问题来了
- 使你的WebService可以远程点击“调用”
- VC编的DLL,在W7,W2003中可以被PB调用,但在W2008R2中就不行,求高手解惑
- 解决mysql本地登陆可以,远程登陆不行的问题
- webservice跨域文件,好多年前的东西,远程调用,js服务器端使用,可以远程调用
- Firefox默认可以调用JSON.stringify而IE却不行
- 使你的WebService可以远程调试点击“调用”
- android 时间选择器和日期选择器,sdk上说可以实现自动同步,貌似不行
- WebService可以远程调试调用
- 使你的WebService可以远程调试点击“调用”
- python 抓取request信息,各种cookie,user-agent类的信息,只调试到http可以抓取,https貌似不行。
- python selenium chrome使用代理自动登录,并可以远程调用
- 奥运门票可以网上卖,火车票为什么不行
- jwplayer xp测试ok chrome可以firfox ie 360不行 貌似不能解码
- android客户端与服务器交互数据(基于SAOP协议的远程调用标准,通过webservice可以将不同操作系统平台,不同语言,不同技术整合)
- win7系统可以远程可以ping通,但是访问不行处理
- 使用 RMI + ZooKeeper 实现远程调用框架
- 水经注可以提供哪些二维地图发布源码调用实例?
- 通过java反射调用远程方法