Showing posts with label connect. Show all posts
Showing posts with label connect. Show all posts

Monday, March 26, 2012

How to fix this error? (There is already an open DataReader associated with this Command w

This is my code:

1If Session("ctr") = False Then23 Connect()45 SQL = "SELECT * FROM counter"6 SQL = SQL & " WHERE ipaddress='" & Request.ServerVariables("REMOTE_ADDR") & "'"7 dbRead()89 If dbReader.HasRows = True Then1011 dbReader.Read()12 hits = dbReader("hits")13 hits = hits + 114 dbClose()1516 SQL = "UPDATE counter SET hits=" & hits17 SQL = SQL & " WHERE ipaddress='" & Request.ServerVariables("REMOTE_ADDR") & "'"18 dbExecute()1920 Else2122 SQL = "INSERT INTO counter(ipaddress,hits)"23 SQL = SQL & " VALUES('" & Request.ServerVariables("REMOTE_ADDR") & "',1)"24 dbExecute()2526 End If2728 Session("ctr") = True2930 End If
 
1Public Sub Connect()2 Conn = New SqlConnection("Initial Catalog=NURSETEST;User Id=sa;Password=sa;Data Source=KSNCRUZ")3 If Conn.State = ConnectionState.Open Then4 Conn.Close()5 End If6 Conn.Open()7 End Sub89 Public Sub Close()10 Conn.Close()11 Conn = Nothing12 End Sub1314 Public Sub dbExecute()15 dbCommand = New SqlCommand(SQL, Conn)16 dbCommand.ExecuteNonQuery()17 End Sub1819 Public Sub dbRead()20 dbCommand = New SqlCommand(SQL, Conn)21 dbReader = dbCommand.ExecuteReader22 End Sub2324 Public Sub dbClose()25 SQL = ""26 dbReader.Close()27 End Sub
 

You should always call the Close method when you have finished using theDataReader object. and also set dbReader Object = nothing and re intialized the object on next use

|||

1 If Session("ctr") = False Then
2
3 Connect()
4
16 SQL = "UPDATE counter SET hits=hits+1"
17 SQL = SQL & " WHERE ipaddress='" & Request.ServerVariables("REMOTE_ADDR") & "'"

SQL = SQL & " IF @.@.Rowcount=0"
22 SQL =SQL & " INSERT INTO counter(ipaddress,hits)"
23 SQL = SQL & " VALUES('" & Request.ServerVariables("REMOTE_ADDR") & "',1)"
24 dbExecute()
25 Close()

27
28 Session("ctr") = True
29
30 End If

sql

Monday, March 19, 2012

How to find SQL Server machine configration

I have SQL Server client installed on my machine, through which I connect to SQL Server A. Is there any way, in which I can find out the configration of the machine on which SQL Server A is installed. I am interested in finding out the number of processors and the amount of RAM.

If you're using SQL Server 2005 and have sysadmin privileges or more specifically the VIEW_SERVER_STATE permission you can run the following command:

SELECT * FROM sys.dm_os_sys_info

You can see [cpu_count] and [hyperthread_ratio] as well as [physical_memory_in_bytes]

For more information, please check out the Books Online documentation: http://msdn2.microsoft.com/en-us/library/ms175048.aspx.

Paul A. Mestemaker II
Program Manager
Microsoft SQL Server Manageability
http://blogs.msdn.com/sqlrem/

|||

Hi Paul,

Thanks for the info.

But I am currently trying to find the machine config of SQL Server 2000. Is there a equivalent query for that. Sorry I didn't specify the SQL Server version in the previous post.

|||

You should upgrade :-P

For SQL Server 2000, I'm not sure. Have you tried EXEC xp_msver?

Paul A. Mestemaker II
Program Manager
Microsoft SQL Server Manageability
http://blogs.msdn.com/sqlrem/

|||

EXEC xp_msver gives me the processor count and the processor type.

I think I can go ahead from there. Thanks

Monday, March 12, 2012

How to find out what port an instance use

I use MSDE 2000 and I want to connect over internet to the server. The
problem is that I use an instance and so the port is not 1433 as it applies
dynamically. How can I find out what port the instance use to listen? With
SQL Server I can use Server Network Utility. Does MSDE have a similar tool?
Can I check the port programmatically (I use VB.NET)?
Thanks.
Hello,
From Start -- Run -- Execute svrnetcn.exe
Thanks
Hari
"KFX" <KFX@.discussions.microsoft.com> wrote in message
news:1F259EEA-86C6-4FFE-82B8-BB1BC58551CD@.microsoft.com...
>I use MSDE 2000 and I want to connect over internet to the server. The
> problem is that I use an instance and so the port is not 1433 as it
> applies
> dynamically. How can I find out what port the instance use to listen? With
> SQL Server I can use Server Network Utility. Does MSDE have a similar
> tool?
> Can I check the port programmatically (I use VB.NET)?
> Thanks.

How to find out Usersinfo using JDBC Connection to SQL Server

Hi..
I want to find out the List of users created in SQL Server.
Im using type 4 Driver to Connect SQL Server.
Regards
maruthi.List of active users, users for a database or logins for the sql server ?|||select * from master.dbo.syslogins
select * from master.dbo.sysxlogins
select * from your_database.dbo.sysusers|||Thanks

the problem is solved.

Sunday, February 19, 2012

how to filter IPs that can connect to 1433 ?

Hi,
I have SQL 2005 express running on 2003 server (standard). How do I filter
packets to allow on 2 IP addresses to connect to 1433 ?
My router has a NAT table for port forwarding but I don't have an firewall
rules to filter IP traffic.
Is these a facility on 2003 server or SQL 2005 that would allow me to packet
filter by IP address ?
(guess I could just install ISA server on it but this seems a little
extreme).
Thanks
Scottits ok found the ip security in local policy.

how to filter IPs that can connect to 1433 ?

Hi,
I have SQL 2005 express running on 2003 server (standard). How do I filter
packets to allow on 2 IP addresses to connect to 1433 ?
My router has a NAT table for port forwarding but I don't have an firewall
rules to filter IP traffic.
Is these a facility on 2003 server or SQL 2005 that would allow me to packet
filter by IP address ?
(guess I could just install ISA server on it but this seems a little
extreme).
Thanks
Scottits ok found the ip security in local policy.