Man of Honour
Hi,
I'm trying to set up a .VB Console to run an SQL scrip on a Sybase server.. I found the following from a Google search. It's attempting a connection but nothing more.. I'm a bit puzzled the the code has no user name and password..
Any ideas where I'm going wrong?
Thanks
I'm trying to set up a .VB Console to run an SQL scrip on a Sybase server.. I found the following from a Google search. It's attempting a connection but nothing more.. I'm a bit puzzled the the code has no user name and password..
Code:
Imports System
Imports System.Data
Imports System.Data.OleDb
Module Program
Sub Main(args As String())
Dim ServerName As String = "ServerName:port"
Dim DatabaseName As String = "mydatabase"
Dim DbUserName As String = "user"
Dim DbPassword As String = "password"
Dim DoubleQuote As String = Chr(34)
Dim QueryToExceute As String =
$"{DoubleQuote}select * from table where x = y{DoubleQuote}"
Dim ExportFileName As String =
$"{DoubleQuote}C:\Users\me\Downloads\out.csv{DoubleQuote}"
Dim Process = New Process()
Process.StartInfo.UseShellExecute = False
Process.StartInfo.RedirectStandardOutput = True
Process.StartInfo.RedirectStandardError = True
Process.StartInfo.CreateNoWindow = True
Process.StartInfo.FileName = "SQLCMD.EXE"
Process.StartInfo.Arguments =
$"-S {ServerName} -d {DatabaseName} -E -Q {QueryToExceute} -o {ExportFileName} -h-1 -s"","" -w 700"
Process.StartInfo.WorkingDirectory = "C:\Data"
Process.Start()
Process.WaitForExit()
Console.WriteLine("Done")
Console.ReadLine()
Console.ReadKey()
End Sub
End Module
Any ideas where I'm going wrong?
Thanks