473,386 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Error when trying to create new SQL Server login via ado.Net

I get an error when I try to execute the following code using ADO.Net
in VB.Net:

conn.open
sqlString="CREATE LOGIN test WITH PASSWORD = '1qaz2wsx'"
command=new SqlCommand(sqlString)
command.connection = conn
command.ExecuteNonQuery()

The error occurs when executing the ExecuteNonQuery line and is:

"Line1: Incorrect syntax near 'LOGIN' "

The database connection is connected to the master database of SQL 2005
Express using the sa account. This line executes just fine in Sql
Server Studio Manger when connected as sa. Am I not allowed to create
database logins via ado.net?!?! I need to for my application.

Thx,
Marcus

Mar 28 '06 #1
3 1680
Dear Holysmokes99,

Suppose it should work, the syntax and codes are all correct.
Would you show us the Connection string?
--
Hope this help and welcome to reply the testing result.

Regards
Ken Lin, Kam Hung
Founder and VP of Hong Kong .NET User Group(http://HKNetUG.com)
MCP, MCP+I, MCDST, MCSA, MCSE(NT4 & win2k),
MCSE+I, MCDBA(SQL7 & SQL2K), MCSD(VB6 & .NET), MCAD(.NET)
Microsoft Community Star(Hong Kong & Taiwan)
Microsoft Most Valuable Professional(.NET since 2003)
MCT2004 & 2005

"holysmokes99" <ho**********@hotmail.com> wrote in message
news:11**********************@z34g2000cwc.googlegr oups.com...
I get an error when I try to execute the following code using ADO.Net
in VB.Net:

conn.open
sqlString="CREATE LOGIN test WITH PASSWORD = '1qaz2wsx'"
command=new SqlCommand(sqlString)
command.connection = conn
command.ExecuteNonQuery()

The error occurs when executing the ExecuteNonQuery line and is:

"Line1: Incorrect syntax near 'LOGIN' "

The database connection is connected to the master database of SQL 2005
Express using the sa account. This line executes just fine in Sql
Server Studio Manger when connected as sa. Am I not allowed to create
database logins via ado.net?!?! I need to for my application.

Thx,
Marcus

Mar 29 '06 #2
Hi, KenLin

The connection string is "server=marcus; Initial Catalog=master;
uid=sa;password=whatever!". I am able to connect fine to the database
using this ADO.Net connection as I have just prior to the CREATE LOGIN
command executed several other standard queries on the server.

Cheers,
Marcus

Mar 29 '06 #3
Oh, Jeesh, My bad!!! I was connecting to an
instance of SQL Server 2000, and not SQL Express. I have both on my
machine
and forgot to reference it as "Marcus\SQLEXPRESS", instead using
"Marcus" only. CREATE LOGIN is new for SQL Server 2005 and thus I got a

syntax error when connecting to SQL 2000. Sorry about that!

Marcus

Mar 29 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Marina Anufreichik | last post by:
Hi, After deploymnet web application on web server I can access page on local machine and login fine but when I'm trying to access web site from remote machine I can see login page, but when I'm...
6
by: John Lau | last post by:
Hi, I am looking at the MS KB Article 306355: HOW TO: Create Custom Error Reporting Pages in ASP.NET by Using Visual C# .NET This article describes how to redirect errors to a custom html...
13
by: Edward Mitchell | last post by:
I have a problem that involves the error I receive when attempting to complete the asp.net web application example (Walkthrough: Creating a Web Application Using a Third-Party Business Object). ...
2
by: arsisthesis | last post by:
Hi all, I have a curious problem with the ERROR 1044 and 1045: -system: OS X 10.4.3 (bash shell) -bash schell prompt: /~ kssun$ -I have set passwd to 'kssun' -I set path:...
0
by: ruju00 | last post by:
I am getting an error in Login() method of the following class FtpConnection public class FtpConnection { public class FtpException : Exception { public FtpException(string message) :...
3
by: Ted | last post by:
In WSAT, I get the following error when trying to set up my provider: Could not establish a connection to the database. If you have not yet created the SQL Server database, exit the Web Site...
7
by: Raj | last post by:
I have developed a component create database, sql login,pwd, create tables etc., The component is working fine with VB But the same is not working with ASP as I get this error: Error 800a01a8...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.