Re: OSQL UserName and PWd




"gopal" <gopal.srini@xxxxxxxxx> wrote in message
news:1158921953.475752.251360@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
| Willy
|
| I had tried the foll code, seems its working okay, but i have couple of
| points to be clarified, the following is the code, can you pls verify
| the code..
|
| I want the password to be entered as ******, not as actual characters,
| i am getting the output as
|

In this case you'll have to turn-off the console echo mode. There is no
support for this in the FCL, so you'll have to PInvoke some console API's.
Following is a sample.

using ...
using System.Runtime.InteropServices;
public class class1
{
[DllImport("Kernel32")]
extern static IntPtr GetStdHandle(int inp);
[DllImport("Kernel32")]
extern static bool GetConsoleMode(IntPtr handle, ref uint mode);
[DllImport("Kernel32")]
extern static bool SetConsoleMode(IntPtr handle, uint mode);
static uint ENABLE_ECHO_INPUT = 0x0004;
static void Main() {
...

password = GetPasswordFromConsole();
string osqlArgs = String.Format("....
...
} // end Main

static string GetPasswordFromConsole() {

IntPtr hCon = GetStdHandle(-10);
uint oldMode = 0;
GetConsoleMode(hCon, ref oldMode);
uint newMode = oldMode & ~ENABLE_ECHO_INPUT;
SetConsoleMode(hCon, newMode);
// Prompt user to enter password
Console.Write("Enter password: ");
string pwd = Console.ReadLine();
Console.WriteLine();
SetConsoleMode(hCon, oldMode);
return pwd;
}


| Enter User:sa
| Enter Password:sa
| Process output: 1> 2> 3> (1 row affected)
| Process output: (1 row affected)
|
| i want to supress the 1>2>3 and want to display only the number of rows
| affected as
| 1 row affected
|


Well, just parse the returned string, but I'm affraid you will have to do it
yourself. Hint take a look at the String.Index and String.IndexOf and
String.Substring methods.

Willy.



Willy.




.



Relevant Pages

  • Re: Is C# support load device driver?
    ... how to manage driver loading/unloading using both PInvoke interop and WMI. ... string driverName; ... IntPtr fileHandle; ... databaseName, uint dwDesiredAccess); ...
    (microsoft.public.dotnet.languages.csharp)
  • Is this the right group for this?
    ... public static extern uint WMCreateEditor( ... Public Function ReadAttributes(ByVal pwszFileName As String, ... Dim HeaderInfo3 As IWMHeaderInfo3 ... bool AddAttrib(string pwszFileName, ushort wStreamNum, string ...
    (microsoft.public.windowsmedia.sdk)
  • Re: IStorage::CopyTo throws Invalid Pointer exception
    ... [PreserveSig] ... uint CreateStream( ... string pwcsName, ... int reserved1, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: SHGetFileInfo - Getting blank file type
    ... public IntPtr hIcon; ... public string szDisplayName; ... public static extern IntPtr SHGetFileInfo(string pszPath, uint ... ref SHFILEINFO psfi, uint cbFileInfo, uint uFlags); ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Gmail SMTP
    ... public static void Send(string from, string pwd, string to, string subject, ... Do you have any external program blocking the connection? ...
    (microsoft.public.dotnet.languages.csharp)

Loading