|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Error when trying to create new SQL Server login via ado.Netin 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 Dear Holysmokes99,
Suppose it should work, the syntax and codes are all correct. Would you show us the Connection string? -- Show quoteHide quoteHope 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" <holysmoke***@hotmail.com> wrote in message news:1143588372.890003.112870@z34g2000cwc.googlegroups.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 > 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 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
Class question
Datagrid problem Doing some extra task while saving databind Controls in VB.Net 2005 ? select all text when textbox1 is clicked Auto-stop DUN via VB.Net? Dynamically Loading Programs Adding HTML code to project. Oledb VS Sql. Oledb works with Sql Server; Sql doesn't...why SQL Server and ADO.Net best method Re: ContextSwitchDeadlock was detected |
|||||||||||||||||||||||