You didn't mention which DB you're using.
For help with connection strings, check The connection string reference . After that you may succeed in creating a new login.
Teme64
Veteran Poster
1,031 posts since Aug 2008
Reputation Points: 218
Solved Threads: 203
You replace SQLstr variable when you build the command. You should append commands to previous one (and a linefeed)
SQLStr = "CREATE LOGIN [rx] WITH PASSWORD=N'rx4', DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF" & Environment.NewLine
SQLStr = SQLStr & "EXEC sys.sp_addsrvrolemember @loginame = N'rx', @rolename = N'sysadmin'" & Environment.NewLine
SQLStr = SQLStr & "ALTER LOGIN [rx] ENABLE" & Environment.NewLine
SQLStr = SQLStr & "CREATE DATABASE [RxMa] ON PRIMARY ( NAME = N'RxMa', FILENAME = N'C:\SQL\RxMa.mdf' , SIZE = 3000KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ) LOG ON ( NAME = N'RxMa_log', FILENAME = N'C:\SQL\RxMa_log.ldf' , SIZE = 1024KB , MAXSIZE = 300GB , FILEGROWTH = 10%)" & Environment.NewLine
SQLStr = SQLStr & "ALTER DATABASE [RxMa] SET COMPATIBILITY_LEVEL = 100"
Teme64
Veteran Poster
1,031 posts since Aug 2008
Reputation Points: 218
Solved Threads: 203
VB.NET has a very usefull namespace called My. You can access, for example, computer and filesystem easily with it
Dim origsql_NAME As String = System.Environment.CurrentDirectory & "\setupscripts\templates\dbuser.sql"
If My.Computer.FileSystem.FileExists(origsql_NAME) Then
SQLStr = My.Computer.FileSystem.ReadAllText(origsql_NAME)
Else
MessageBox.Show("dbuser.sql Doesn't Exist at " & System.Environment.CurrentDirectory & "\SQL\setupscripts\templates", "Script Not Found", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
Teme64
Veteran Poster
1,031 posts since Aug 2008
Reputation Points: 218
Solved Threads: 203