OSQL用户名和密码提示。 [英] OSQL userName and Password Prompt.

查看:114
本文介绍了OSQL用户名和密码提示。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我试图从我的C#控制台应用程序调用OSQL实用程序和

i遇到问题


i有以下代码

主要方法


ProcessStartInfo psi = new ProcessStartInfo(" osql","");

psi.RedirectStandardInput = false;

psi.RedirectStandardOutput = true;

psi.RedirectStandardError = false;

psi。 CreateNoWindow = false;

psi.UseShellExecute = false;

Process pc = Process.Start(psi);

Console.WriteLine(pc。 StandardOutput.ReadToEnd());

pc.WaitForExit();


i无法在

命令提示符..

有人可以帮帮我吗?

解决方案

什么这个代码运行时实际发生了吗?


Ciaran O'Donnell


" gopal"写道:





我试图从我的C#控制台应用程序调用OSQL实用程序和

i我遇到问题


i有以下代码

主要方法


ProcessStartInfo psi = new ProcessStartInfo(" osql","");

psi.RedirectStandardInput = false;

psi.RedirectStandardOutput = true;

psi .RedirectStandardError = false;

psi.CreateNoWindow = false;

psi.UseShellExecute = false;

流程pc = Process.Start(psi) ;

Console.WriteLine(pc.StandardOutput.ReadToEnd());

pc.WaitForExit();


i不是能够在命令提示符的

中捕获SQL服务器的用户名和密码..

有人可以帮帮我吗?




" gopal" < go ********* @ gmail.comwrote in message

news:11 ********************* @ b28g2000cwb.googlegro ups.com ...

|

|

|我试图从我的C#控制台应用程序调用OSQL实用程序和

|我有问题

|

|我有以下代码

|在Main方法中

|

| ProcessStartInfo psi = new ProcessStartInfo(" osql","");

| psi.RedirectStandardInput = false;

| psi.RedirectStandardOutput = true;

| psi.RedirectStandardError = false;

| psi.CreateNoWindow = false;

| psi.UseShellExecute = false;

| Process pc = Process.Start(psi);

| Console.WriteLine(pc.StandardOutput.ReadToEnd());

| pc.WaitForExit();

|

|我无法在

|中捕获SQL服务器的用户名和密码命令提示符..

|谁有人可以帮帮我?

|


您需要将它们作为命令参数传递(运行osql /?以获取详细信息)。

我也看不到你想要实现的目标,osql是一个

交互式实用程序,你必须向stdin编写命令并阅读

来自stdout的响应,这是重定向stdin和stdout。为什么不直接从命令行运行

osql?


Willy。


此代码可以正常工作对于我来说,在Windows应用程序和.NET 2中的控制台应用程序中。

它写出来:

错误:没有用户选择。尝试使用-U或-E开关


Ciaran O'Donnell


" gopal"写道:





我试图从我的C#控制台应用程序调用OSQL实用程序和

i我遇到问题


i有以下代码

主要方法


ProcessStartInfo psi = new ProcessStartInfo(" osql","");

psi.RedirectStandardInput = false;

psi.RedirectStandardOutput = true;

psi .RedirectStandardError = false;

psi.CreateNoWindow = false;

psi.UseShellExecute = false;

流程pc = Process.Start(psi) ;

Console.WriteLine(pc.StandardOutput.ReadToEnd());

pc.WaitForExit();


i不是能够在命令提示符的

中捕获SQL服务器的用户名和密码..

有人可以帮帮我吗?


Hi,

I am trying to call the OSQL utility from my C# console application and
i am having problems

i have the following code
In Main method

ProcessStartInfo psi = new ProcessStartInfo("osql","");
psi.RedirectStandardInput = false;
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = false;
psi.CreateNoWindow = false;
psi.UseShellExecute = false;
Process pc = Process.Start(psi);
Console.WriteLine(pc.StandardOutput.ReadToEnd());
pc.WaitForExit();

i am not able to capture the username and password of the SQL server in
the command prompt..
can anyone please help me?

解决方案

What actually happens when this code runs?

Ciaran O''Donnell

"gopal" wrote:

Hi,

I am trying to call the OSQL utility from my C# console application and
i am having problems

i have the following code
In Main method

ProcessStartInfo psi = new ProcessStartInfo("osql","");
psi.RedirectStandardInput = false;
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = false;
psi.CreateNoWindow = false;
psi.UseShellExecute = false;
Process pc = Process.Start(psi);
Console.WriteLine(pc.StandardOutput.ReadToEnd());
pc.WaitForExit();

i am not able to capture the username and password of the SQL server in
the command prompt..
can anyone please help me?



"gopal" <go*********@gmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
| Hi,
|
| I am trying to call the OSQL utility from my C# console application and
| i am having problems
|
| i have the following code
| In Main method
|
| ProcessStartInfo psi = new ProcessStartInfo("osql","");
| psi.RedirectStandardInput = false;
| psi.RedirectStandardOutput = true;
| psi.RedirectStandardError = false;
| psi.CreateNoWindow = false;
| psi.UseShellExecute = false;
| Process pc = Process.Start(psi);
| Console.WriteLine(pc.StandardOutput.ReadToEnd());
| pc.WaitForExit();
|
| i am not able to capture the username and password of the SQL server in
| the command prompt..
| can anyone please help me?
|

You need to pass them as command arguments (run osql /? for details).
I also do not see what you are trying to achieve here, osql is an
interactive utility, you will have to write commands to stdin and read
responses from stdout, that is redirect stdin and stdout. Why not simply run
osql from the command line?

Willy.


This code works for me inside a windows app and a console app in .NET 2.
It writes out:
Error: No user selected. Try with -U or -E switches

Ciaran O''Donnell

"gopal" wrote:

Hi,

I am trying to call the OSQL utility from my C# console application and
i am having problems

i have the following code
In Main method

ProcessStartInfo psi = new ProcessStartInfo("osql","");
psi.RedirectStandardInput = false;
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = false;
psi.CreateNoWindow = false;
psi.UseShellExecute = false;
Process pc = Process.Start(psi);
Console.WriteLine(pc.StandardOutput.ReadToEnd());
pc.WaitForExit();

i am not able to capture the username and password of the SQL server in
the command prompt..
can anyone please help me?


这篇关于OSQL用户名和密码提示。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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