Thursday, March 29, 2012
Error when trying to create new SQL Server login via 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,
MarcusHi
It seems to be something wrong with quoatations. Print the sqlString and see
if you can execute it in QA
"holysmokes99" <holysmokes99@.hotmail.com> wrote in message
news:1143588567.138045.218660@.j33g2000cwa.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
>|||I suggest you double check your connection string to make sure you are
connected to the SQL Express instance since this message indicates you are
connected to a pre-SQL 2000 instance. You can insert code like the example
below to query the instance version. My SQL Express instance returns
"9.00.1399.06".
command=new SqlCommand("SELECT SERVERPROPERTY('ProductVersion')")
Dim version as String = command.ExecuteScalar().ToString()
MessageBox.Show(version)
Hope this helps.
Dan Guzman
SQL Server MVP
"holysmokes99" <holysmokes99@.hotmail.com> wrote in message
news:1143588567.138045.218660@.j33g2000cwa.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
>|||> It seems to be something wrong with quoatations. Print the sqlString and
> see if you can execute it in QA
No need to print the SQL statement here since it is in clear text in Marcus'
code snippet:
CREATE LOGIN test WITH PASSWORD = '1qaz2wsx'
Hope this helps.
Dan Guzman
SQL Server MVP
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:eVeLQavUGHA.4436@.TK2MSFTNGP10.phx.gbl...
> Hi
> It seems to be something wrong with quoatations. Print the sqlString and
> see if you can execute it in QA
>
> "holysmokes99" <holysmokes99@.hotmail.com> wrote in message
> news:1143588567.138045.218660@.j33g2000cwa.googlegroups.com...
>|||Hi,Dan
Yep, I got it. thanks
"Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
news:uahPs5yUGHA.5900@.tk2msftngp13.phx.gbl...
> No need to print the SQL statement here since it is in clear text in
> Marcus' code snippet:
> CREATE LOGIN test WITH PASSWORD = '1qaz2wsx'
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Uri Dimant" <urid@.iscar.co.il> wrote in message
> news:eVeLQavUGHA.4436@.TK2MSFTNGP10.phx.gbl...
>|||Oh, Jeesh, My bad!!! Dan you were spot on. I was connecting to an
instance of SQL Server 2000, and not 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. Thanks for your insight.
On a sort-of-related note, is there a way for me to iterate through all
the SQL Server Express instances on the network? Using SQL-DMO, the
code below gives me the names of the servers, but some of the SQL
Express servers are named "[server_name]\SQLEXPRESS", while others are
just "[server_name]" (even though they do not have anything other that
SQL Express on them). If they were all suffixed with "SQLEXPRESS" then
that would be easy, but it doesn't seem to work that way.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim oNames As SQLDMO.NameList
Dim oSQLApp As SQLDMO.Application
Dim oServer As SQLDMO.SQLServer2
oSQLApp = New SQLDMO.Application
oNames = oSQLApp.ListAvailableSQLServers
For i As Integer = 1 To oNames.Count
TextBox1.AppendText(oNames.Item(i) + Environment.NewLine)
Next
End sub
Thanks!
Marcus|||Check the following:
1) SQL Brower service is enabled and running
2) Port 1434 isn't blocked (e.g. Windows firewall)
3) The SQL Express instance is configured for remote connections
Hope this helps.
Dan Guzman
SQL Server MVP
"Marcus" <holysmokes99@.hotmail.com> wrote in message
news:1143659183.191249.143360@.e56g2000cwe.googlegroups.com...
> Oh, Jeesh, My bad!!! Dan you were spot on. I was connecting to an
> instance of SQL Server 2000, and not 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. Thanks for your insight.
> On a sort-of-related note, is there a way for me to iterate through all
> the SQL Server Express instances on the network? Using SQL-DMO, the
> code below gives me the names of the servers, but some of the SQL
> Express servers are named "[server_name]\SQLEXPRESS", while others are
> just "[server_name]" (even though they do not have anything other that
> SQL Express on them). If they were all suffixed with "SQLEXPRESS" then
> that would be easy, but it doesn't seem to work that way.
> Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button2.Click
> Dim oNames As SQLDMO.NameList
> Dim oSQLApp As SQLDMO.Application
> Dim oServer As SQLDMO.SQLServer2
> oSQLApp = New SQLDMO.Application
> oNames = oSQLApp.ListAvailableSQLServers
> For i As Integer = 1 To oNames.Count
> TextBox1.AppendText(oNames.Item(i) + Environment.NewLine)
> Next
> End sub
>
> Thanks!
> Marcus
>|||Thanks, Dan. You were right again. On the machine with SQL Express
only, Windows Firewall was on. When I disabled it, the server name and
sql server instancen name came up when I ran the code above, i.e.
"training\sqlexpress", not just the server name as before when firewall
was active. Why did the server name come up at all then when the
firewall was enabled, when using the SQL-DMO code above?
Cheers,
Marcus|||> Why did the server name come up at all then when the
> firewall was enabled, when using the SQL-DMO code above?
IIRC, before SQL Server 2000, network broadcast packets sent to facilitate
server enumeration. According to Perter's blog
(http://blogs.msdn.com/sql_protocols.../24/473502.aspx), legacy
behavior can show default instances even with UDP 1434 blocked.
Hope this helps.
Dan Guzman
SQL Server MVP
"Marcus" <holysmokes99@.hotmail.com> wrote in message
news:1143736505.471840.78380@.i39g2000cwa.googlegroups.com...
> Thanks, Dan. You were right again. On the machine with SQL Express
> only, Windows Firewall was on. When I disabled it, the server name and
> sql server instancen name came up when I ran the code above, i.e.
> "training\sqlexpress", not just the server name as before when firewall
> was active. Why did the server name come up at all then when the
> firewall was enabled, when using the SQL-DMO code above?
> Cheers,
> Marcus
>sql
Friday, March 23, 2012
Error when logging on to sql server proper
I am getting the following error.
"The user instance login flag is not supported on this version of SQL Server. The connection will be closed."
Background i created a site on my development machine, and every thing worked, this computer is running sql EX. I uploaded the site to the production server (running sql 2005 standard) and changed the connection string (i have used this connection string with other dB's to display data only, and it works) but i tried it with the ASPNETDB.mdf in the AppData folder and i get the above message.
Do i have to set some special permissions in the db for it to work. I need to be able to insert, update, and delete in this app.
The definition for the 'User Instance' attribute in connection string is as following:
User Instance
A value that indicates whether to redirect the connection from the default SQL Server Express instance to a runtime-initiated instance running under the account of the caller.
I have been able to setup a db that will allow me to do the updates and inserts but with the ASPNETDB.MDF no go. This is the string i'm using:
<connectionStrings>
<addname="ConnectionString"connectionString="server=serversName\XPRESS;uid=aspuser;pwd=aspuserPassworkd;database=DATABName" />
</connectionStrings>
It was a problem with permissions and use. Needed to set user to odb
Thanks for the help though
Monday, March 12, 2012
Error when connecting for the first time
Hi, I get the below error (after clicking login in my home page, so home page works well) when I open my website for the first time after I restart my server or my client machine.
" Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding."
From the next time onwards it is connecting without any problems.
can anyone figure out what could be the problem here?
Are you running SqlExpress?
Did you set the service to start when the server starts? Otherwise it may be getting started on first call and that adds overhead (time) and may be the issue.
|||Yes I use SQLExpress.
Services are fine. It is in autostart mode and so running automatically everytime i restart.
|||Hmm... more then likely either some service or some precompilation is in need of being done.
If you leave your site untouched for an hour and come back, does it timeout again? Trying to see if it's a service or simply the first-hit drain on the system thats causing the issue.
|||this happens only when i use for the first timewww.XXXXXX.com...
I missed the below in my first post and added now
"after clicking login in my home page, so home page works well"
|||Sounds like that's the first call to the DB... so that's most likely the issue.
You may want to hit up the SqlExpress forum...perhaps someone who watches that one will know more but I know I've had it happen in the past but not with regularity... try prefiring a call to the DB from the Application_Start in the global.asax perhaps, to take that initial hit...
Friday, February 24, 2012
error to register the msde2000 in enterprise manager
can anyone tell what can i do to register the msde in enterprise manager, it prompt me the 'sa' login fail. should the name pipe
protocol included or TCP/IP is already ok? thanks.
hi,
"CWeb@.office" <a@.b.com> ha scritto nel messaggio
news:%23AcFcAioEHA.4032@.TK2MSFTNGP15.phx.gbl
> Hi all,
> can anyone tell what can i do to register the msde in enterprise
> manager, it prompt me the 'sa' login fail. should the name pipe
> protocol included or TCP/IP is already ok? thanks.
MSDE installs by default allowing only trusted connections and not SQL
Server authenticated connections
in order to modify this behaviour at install time you have to pass the
additional parameter
SECURITYMODE = SQL
to the command line setup.exe boostrappert installer
you can have a look at
http://support.microsoft.com/default...b;en-us;285097 for
additional information about that, including further info on how to change
this setting after install hacking the windows registry
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz/DbaMgr.shtmhttp://italy.mvps.org
DbaMgr2k ver 0.9.1 - DbaMgr ver 0.55.1
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
-- remove DMO to reply