Showing posts with label sqlserver. Show all posts
Showing posts with label sqlserver. Show all posts

Friday, March 30, 2012

runtime error 3265: item cannot be found in this collection

Hello!

I connected to sqlserver 7 db from vb6.I got one record displayed from my db table as rs.fields(0).If i give rs.fields(1) , it gives me the error, item cannot be found in this collection.When i dispalyed the record count as msgbox rs.recordcount it shows -1.what may be the error, pls help.

LydiaPlease provide your sql statement within vb - and which cursorlocation are you setting (client or server). It sounds like your sql statement is only returning 1 column. When you use rs.fields(1) accesses the 2nd column returned by your sql query - not the next record in the recordset.|||Hello!

Thank you very much, i fixed the error as soon as i written to you.That is the same thing that you replied.It's coz i am quite new to VB and am learning.

Two more issues - i need ur help

1. But still i am getting the record count as -1 . why is it? but i am getting all my records in the record set.

2. I created a function to fill up the list box as

Function FillList(Listitem as Listbox, FieldName as Field, TableName as Table)

--Code--Goes here

End Function

when i tried to call the function as

FillList(List1, m_email,members)

it is returning error as : ByVal ref argument type mismatch

how should i refer the values with the arguments in the function?

Pls help

Lydia|||Which cursorlocation are you using ?|||Originally posted by rnealejr
Which cursorlocation are you using ?

What do you mean by cursor location? i gave the code like this:

--some code here--
opened the record set as AdopenforwardOnly|||Both the connection and recordset objects contain a property called cursorlocation. If you are not setting it, go into debug and view the properties of the object and examine the cursorlocation property.|||Thank you very much, After setting the cursor location, i got the correct record count.|||Happy to help.|||I have a function to fill up list box with a DB Field values as

Public Function FillList(ListItem As ListBox, FieldName As Field,TableName as Table)
Dim i As Integer
i = 0
DbConnect
strSQL = "select FieldName from TableName"

'without using the connection object
ObjRs.Open strSQL, strConn

' Add Items in the list box
ObjRs.MoveFirst
Do While Not ObjRs.EOF
ListItem.AddItem ObjRs(0), i
ObjRs.MoveNext
i = i + 1
Loop

'Be sure you close and destroy your objects.

ObjRs.Close
ObjConn.Close
Set ObjConn = Nothing
Set ObjRs = Nothing
End Function

' Then i called the function as

call FillList(List1,"M_email","Members")

It gives me error as : Type Mismatch

What is the mistake in the code?|||Please post the code before the FillList. How are the Field and Table referenced ( like through adodb ...) ?|||Yes, I connected to the DB as ADODB.Connection|||How are you able to reference "Table" ? Also, you should be explicit in your declarations (Adodb.Field).

The problem is that you are trying to pass a string to a function expecting an object. Both the field/table should be strings - so you would build your sql statement like:

strSQL = "select " & FieldName & " from " & TableName

Wednesday, March 21, 2012

Running SQLServer and SQLServer Agent as Power User

We're trying to limit the number of user accounts with Admin level permissio
n
on our Win2K servers, especially SQL servers. We have created a domain level
account to run SQLServer and SQLAgent. We'd like to limit it to Power User
status instead of Admin status on the servers, but we cannot seem to start
and stop the services from SEM with only Power User status. We've checked
registry key permissions and everything seems to be configured properly. Is
this configuration even possible? Or does this account NEED to be local admi
n
on the server? Help would be appreciated. Thanks.The account that starts the services needs to have the "log on as a service"
right. Without this MSSQLServer and MS SQL Server Agent will not start.
It would also be more secure to use a domain account for this rather than a
local account as SQL then benefits from the integrated security of Windows
2000.
Also why would you want end users to have admin rights on the server at all?
This defeats the object of system security and resource accessibility. It
is best that they are Doman Users only then assign access rights to shares
on the servers.
HTH
Regards
Dazza
"gbledsoe" <gbledsoe@.discussions.microsoft.com> wrote in message
news:72CDD311-3C73-480E-9734-3E6F0E76DB09@.microsoft.com...
> We're trying to limit the number of user accounts with Admin level
> permission
> on our Win2K servers, especially SQL servers. We have created a domain
> level
> account to run SQLServer and SQLAgent. We'd like to limit it to Power User
> status instead of Admin status on the servers, but we cannot seem to start
> and stop the services from SEM with only Power User status. We've checked
> registry key permissions and everything seems to be configured properly.
> Is
> this configuration even possible? Or does this account NEED to be local
> admin
> on the server? Help would be appreciated. Thanks.|||We've following the instructions in MS article 283811 and ensured that the
account has all necessary extended user rights, such as act as part of
operating system, logon as batch job, logon as service. The fundamental
question is whether the account can run as Power User or does it need to be
Administrator? If it does not NEED to be Administrator, what other
configuration is necessary to let us use that account to stop and start the
SQLServer service, since Power User does not seem to have the rights. Thanks
.
"Dazza" wrote:

> The account that starts the services needs to have the "log on as a servic
e"
> right. Without this MSSQLServer and MS SQL Server Agent will not start.
> It would also be more secure to use a domain account for this rather than
a
> local account as SQL then benefits from the integrated security of Windows
> 2000.
> Also why would you want end users to have admin rights on the server at al
l?
> This defeats the object of system security and resource accessibility. It
> is best that they are Doman Users only then assign access rights to shares
> on the servers.
> HTH
> Regards
> Dazza
>
> "gbledsoe" <gbledsoe@.discussions.microsoft.com> wrote in message
> news:72CDD311-3C73-480E-9734-3E6F0E76DB09@.microsoft.com...
>
>|||gbledsoe wrote:
> We're trying to limit the number of user accounts with Admin level permiss
ion
> on our Win2K servers, especially SQL servers. We have created a domain lev
el
> account to run SQLServer and SQLAgent. We'd like to limit it to Power User
> status instead of Admin status on the servers, but we cannot seem to start
> and stop the services from SEM with only Power User status. We've checked
> registry key permissions and everything seems to be configured properly. I
s
> this configuration even possible? Or does this account NEED to be local ad
min
> on the server? Help would be appreciated. Thanks.
It should be, although not all sql feature are available. I am running
multiple instances with different plain domain user accounts. When you are
not sure about registry, user and ntfs permission change the account using
the enterprise manager.
When you need the proxy account to run scheduled dts packages create a
separate account for the sql agent service and make it local admin, unless
someone here can explain how to accomplice this without local admin rights.
have a look at this one:
http://support.microsoft.com/defaul...;283811&sd=tech
Hans