As a beginner, I'm attempting to set up security for SQL Server But it's not working and am fairly confused at the moment.
The current problem is to do with getting SQL Security logins to work. I've added a login for a 'reader' user (no updates allowed) and have set the database user to use only the 'db_datareader' role. Yet, when I logon as that user, I can update data without a problem.
The system is a standalone PC using XP Pro with SQL Express installed.
The connection string is valid (and works, allowing access to all data) and is of the type:
"server=xxxxx;database=xxxx;Trusted_Connection=True;"
The application is written is VB.NET
I hope I'm making some simple mistake here and I'd really appreciate any thoughts ...
as far as I know from docs and forum datareader is for .NET data in memory. So if a use a complex dataflow to build up some data and want to use this in other dataflow componens - could i use data datareader source in the fist dataflow and then use a datareader souce in the second dataflow do read the inmemoty data from fist transform to do fursther cals ?
how to pass in memory data from one dataflow to the next one (i do not want to rebuild the logic in each dataflow to build up data data ?
Is there a way to do this ? and is the datareader the proper component ? (because its the one and only inmemory i guess, utherwise i need to write to temp table and read from temp table in next step) (I have only found examples fro .NET VB or C# programms to read a datareader, but how to do this in SSIS directly in the next dataflow?
I have posted this issue for a week, haven't got any reply yet, I posted it again and desperately need your help.
The article http://msdn2.microsoft.com/en-us/library/ms365343.aspx says: Model Item Security can be set for differnt security filters, but when I use SQL Server Management Studio to set Model Item Security, it seems "Permissions" property surpass "Model Item Security" property. -- My report server is using Custom Authentication.
For example, in "Permissions" property of the model, if I checked "Use these roles for each group or user account" without setting any user or group, no matter what users I added to "Model Item Security" with "Secure individual model items independently for this model" checked, NO one user can see the model on report manager and report builder;
in above situation, if I added "user1" and gave role such as "Browser" role to "user1" in "Permissions" property, if I checked "Secure individual model items independently for this model" in "Model Item Security" property, even I did NOT grant "user1" to root model and any entities under the model, the "user1" is able to access the model and all entities in report builder.
My question is on the same report model, how to set "AdminFilter" (empty security filter) for administrator permissions and set "GeneralFilter" (filtered on UserID) for general user based on their UserID?
The article also says:
"Security filters are always applied, even for users who have Content Manager or Administrator permissions to the model. To allow administrators or other users to see all rows of an entity on which row-level security is defined, you can create an empty security filter (which always returns True) and then use the filter to grant those users access to all the rows."
So I defined 2 filters "GeneralFilter" and "AdminFilter" for "Staff" entity for my report model "SSRSModel", I expect after I deployed the report model, the administrator users use report builder to build reports with all rows available, and the non-admin users can only see rows based on their UserID.
I can only get one result at a time but not both:
either the rows are filtered or not filtered at all, no matter how I set the "SecurityFilter" for the entity: I tried setting both "AdminFilter" and "GeneralFilter" for SecurityFilter at the same time, combination of "DefaultSecurityFilter" and "SecurityFilter", or one at a time.
Hey guys, whats an easy way to pass a value into a stored procodure? I tried the code below but I keep on getting a "Procedure 'sp_InsertData' expects parameter '@gpiBatchNo', which was not supplied." error. My stored proc basically gets inserts the passed variable into a databaseSqlConnection sqlSecConnection = new SqlConnection(sqlPriConnString);SqlCommand sqlSecCommand = new SqlCommand(); sqlSecCommand.Connection = sqlSecConnection; sqlSecCommand.CommandText = "sp_InsertData";sqlSecCommand.CommandType = CommandType.StoredProcedure;sqlSecCommand.Parameters.Add("@gpiBatchNo", SqlDbType.NVarChar) ; sqlSecConnection.Open();int returntype = sqlSecCommand.ExecuteNonQuery(); sqlSecConnection.Close();
Is there any possibility to schedule SQL job execution as Windows Security Group? I need to run powershell script through SQL job with one of this group member's permissions.
I have Sql Server Express installed on Vista (service pack 2)
I have Visual Studio 2005 with an application that I'm trying to access it with within a WCF service.
The login ID of the service is added to the database.
The database has remote access turned on.
The ID is granted access to all databases within the server.
The thread is being set with WindowsProvider and the services set their thread to WindowsProvider.
The dataserver is set with using Windows Authentication for security.
When I open my connection to the database, though, it reports the typically useless message that the connection is not allowed and that the server may not allow remote connections.
How to I get past this? I've done everything right.
I want to use an Active Directory security group that is a Distribution List for a new role assignment for an existing report. Can someone tell me if this is possible? I get an error each time I try:
The user or group name <DLName> is not recognized. (rsUnknownUserName)"
Hi, I am facing a problem to access datareader... actually i want to get data on lables from datareader. actually i am having one table having only one column and i hav accessed all data into datareader but the problem is that i just want to get data row by row...
For example there are four labels Label1, Label2, Label3, Label4 and want to print the data from datareader on to thease labels....
Hi, What is the difference b/w sqldatareader and sqldataadapter? For what purpose are they used in a database connection & how do they differ from each other? Pls explain me in detail.Regards Vijay.
i need help to know what is the best practice i have a stored proc which returns 4 different resultselts will that be easy to use dataset or datareader? my purpose of using dataset/datareader is to load the data in a class thanks.
Hi, I cant seem to get this working right...I have a datareader which i loop through...i want to test each value to see if its null but i cant get the syntax right. I know i use dr.item("columnname") or dr(0) to pick a certain column but i dont know the column names and want to check them all anyway. What is the syntax to do this. Thanks for any help...this is prob very simple but just cant see it. --------------------------------------------While dr.Read If dr(0) Is System.DBNull.Value Then Return "test"End If End While
Hello i creae one programm, there is an two data reader and two Gridview or datagrid , and my programm have one error my programm is there using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class aries : System.Web.UI.Page{ SqlConnection con; SqlCommand cmd; SqlDataReader dr; SqlDataReader dr1; SqlCommand cmd1; protected void Page_Load(object sender, EventArgs e) { string str; str = ConfigurationSettings.AppSettings["DBconnect"]; con = new SqlConnection(str); con.Open(); cmd = new SqlCommand("select color from zodiac_color where Sno=1", con); dr = cmd.ExecuteReader(); GridView1.DataSource = dr; GridView1.DataBind(); cmd1=new SqlCommand("select number from zodiac_number where Sno=1",con); dr1 = cmd.ExecuteReader(); GridView2.DataSource = dr1; GridView2.DataBind(); }} i want to calll two value in a same database but the table is diffrent so please help me ?The error is ::--------- There is already an open DataReader associated with this Command which must be closed first. please help me ashwani kumar
hi to all , check this once..this all data related to bus seats SeatNo1,SeatNo2 seats varchar in databaseSt1,St2 status(bit in database sqlserver2000) All my code is working when reader[i + 2].ToString() == "True" is remove from code ..so plz tell me solution gow to ckeck status with datareaderSqlCommand command = new SqlCommand("Select SeatNo1,SeatNo2,St1,St2 from tblSts where BUSID='S0008'", sqlCon);
Hi In my web site I call all the content from the database with the use of querystrings. I use datareader to call the data each time a request appears from the querystring. Although I close all the connections I still get occasionally the following error: Timeout expired the timeout period elapsed prior to obtaining a connection from the pool. This may have occured because all pooled connections were in use and max pool size was reached.
If it is not a programming error then what could it be? I use sql server 2005 and vs 2005 asp.net 2.0 .
"There is already an open datareader associated with this command which must be closed first." I have received this same error before, but I'm not sure why I'm getting it here.'Create a Connection object. MyConnection = New SqlConnection("...............................")
'Check whether a TMPTABLE_QUERY stored procedure already exists. MyCommand = New SqlCommand("...", MyConnection)
With MyCommand 'Set the command type that you will run. .CommandType = CommandType.Text
'Open the connection. .Connection.Open()
'Run the SQL statement, and then get the returned rows to the DataReader. MyDataReader = .ExecuteReader()
'Try to create the stored procedure only if it does not exist. If Not MyDataReader.Read() Then .CommandText = "create procedure tmptable_query as select * from #temp_table"
MyDataReader.Close() .ExecuteNonQuery() Else MyDataReader.Close() End If
.Dispose() 'Dispose of the Command object. MyConnection.Close() 'Close the connection. End With As you can see, the connection is opened and closed, and the datareader is closed. Here's what comes next...'Create another Connection object. ESOConnection = New SqlConnection("...")
If tx_lastname.Text <> "" Then If (InStr(sqlwhere, "where")) Then sqlwhere = sqlwhere & " AND lname like '" & Replace(tx_lastname.Text, "'", "''") & "%'" Else sqlwhere = " where lname like '" & Replace(tx_lastname.Text, "'", "''") & "%'" End If End If If tx_firstname.Text <> "" Then If (InStr(sqlwhere, "where")) Then sqlwhere = sqlwhere & " AND fname like '" & Replace(tx_firstname.Text, "'", "''") & "%'" Else sqlwhere = " where fname like '" & Replace(tx_firstname.Text, "'", "''") & "%'" End If End If
dynamic_con = sqlwhere & " order by arr_date desc "
'create the temporary table on esosql. CreateCommand = New SqlCommand("CREATE TABLE #TEMP_TABLE (".............", ESOConnection)
With CreateCommand 'Set the command type that you will run. .CommandType = CommandType.Text
'Open the connection to betaserv. ESOConnection.Open()
'Run the SQL statement. .ExecuteNonQuery()
End With
'query our side ESOCommand = New SqlCommand("SELECT * FROM [arrest_index]" & dynamic_con, ESOConnection)
'loop through recordset and populate temp table While ESODataReader.Read()
MyInsert = New SqlCommand("INSERT INTO #TEMP_TABLE VALUES("......", ESOConnection)
'Set the command type that you will run. MyInsert.CommandType = CommandType.Text
'Run the SQL statement. MyInsert.ExecuteNonQuery()
End While
ESODataReader.Close() 'Create a DataAdapter, and then provide the name of the stored procedure. MyDataAdapter = New SqlDataAdapter("TMPTABLE_QUERY", ESOConnection)
'Set the command type as StoredProcedure. MyDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure
'Create a new DataSet to hold the records and fill it with the rows returned from stored procedure. DS = New DataSet() MyDataAdapter.Fill(DS, "arrindex")
'Assign the recordset to the gridview and bind it. If DS.Tables(0).Rows.Count > 0 Then GridView1.DataSource = DS GridView1.DataBind() End If
'Dispose of the DataAdapter MyDataAdapter.Dispose()
'Close server connection ESOConnection.Close() Again, a separate connection is open and closed.I've read you can only have 1 datareader available per connection. Isn't that what I have here? The error is returned on this line: MyInsert.ExecuteNonQuery() Help is appreciated.
I am using a datareader to access data via a stored procedure. The reason for using the datareader is that the stored procedure is multi level depending on the variable sent to it. However I want to do two things with the data being returned.
The first is to poulate a datagrid - which I've done. The second is to produce an Infragistic Web Graph. However according to the background reading I have done so far, I can only populate the graph from one of the following: datatable,dataview,dataset,Array or Ilist.
I don't want to make another call to the server for the same information, so how can I get the data out of a stored procedure into a dataset or dataview?
Dim objCon2 As New SqlConnection() objCon2.ConnectionString = "a standard connection string" objCon2.Open()
Dim objCommand As SqlCommand objCommand = New SqlCommand(strSQL, objCon2) Dim objReader As SqlDataReader objReader = objCommand.ExecuteReader()
Label1.Text = objReader("email")
strSQL is a select command which I've checked (using SQL Query analyzer) does return data. I know the connection string is valid (and I presume if it wasn't that it'd fail on objCon2.open, which it doesn't).
So why oh why do I get this error on the last line (and yes, there is an "email" field in the contents of the reader)
System.InvalidOperationException: Invalid attempt to read when no data is present.
I have data I am retrieving using a datareader...and SQLSERVER It could return 1 row of information or perhaps 3 rows of information I need to know how to use an array here I would guess so I can access each element in this row or rows.
HOw might I use reader.read and get it into the array
I want to create a DataList that shows products, which will be on multiple pages. I have my stored proc to show paged results, which contains a return value for more records. I have found examples of coding the DataReader, defining all the parameters etc, but what about the drag and drop SqlDataSource?? You can select the DataSource Mode to be "DataReader". I can put select parameters in, with input and my return value. I don't know how to then access the return value, or output value if needed, from this? My DataList references the SqlDataSource, but I don't know how to get the return/output value out??? This is very frustrating, cause I can't find any info about it anywhere. Always input parameters, but no output. This is my current SqlDataSource...
If I take out the RETURN_VALUE Parameter, my results display in my data list, but that's useless if I can't access the return value to determine the remaining number of pages etc. Is my RETURN_VALUE parameter wrong? How do I access that? My stored proc is shown below...
CREATE PROCEDURE sp_PagedItems ( @Page int, @RecsPerPage int, @CategoryID int ) AS
-- We don't want to return the # of rows inserted -- into our temporary table, so turn NOCOUNT ON SET NOCOUNT ON
--Create a temporary table CREATE TABLE #TempItems ( ID int IDENTITY, No varchar(100), Name varchar(100), SDescription varchar(500), Size varchar(10), ImageURL varchar(100) )
-- Insert the rows from tblItems into the temp. table INSERT INTO #TempItems (No, Name, SDescription, Size, ImageURL) SELECT No, Name, SDescription, Size, ImageURL FROM Products WHERE CategoryID=@CategoryID
-- Find out the first and last record we want DECLARE @FirstRec int, @LastRec int SELECT @FirstRec = (@Page - 1) * @RecsPerPage SELECT @LastRec = (@Page * @RecsPerPage + 1)
-- Now, return the set of paged records, plus, an indiciation of we -- have more records or not! SELECT *, MoreRecords = ( SELECT COUNT(*) FROM #TempItems TI WHERE TI.ID >= @LastRec ) FROM #TempItems WHERE ID > @FirstRec AND ID < @LastRec
I am very disappinted where Datareader have no RecordCount where I can get the total records it read. I guess I found a way:
sql = "SELECT *, ROW_NUMBER() OVER (ORDER BY id DESC) AS c FROM ACCOUNTS ORDER BY c DESC"Dim command As SqlCommand = New SqlCommand(sql, New SqlConnection(_DBConnectionString)) command.Connection.Open() _ReturnDataReader = command.ExecuteReader(CommandBehavior.CloseConnection) command.Dispose() _TotalRecord = _ReturnDataReader.GetInt64(_ReturnDataReader.GetOrdinal("c")) Have SQL Server 2005 count for me....
Hi All, I am the following problem retrieving Float data from a Compact SQL database, it worked perfectly with 1.1 .Net CF, but since updating to 2.0 .Net CF its crashing with a "InvalidCastException" Error, have checked the DB its a Float...
I have the following SQL statement in the DataReader.SQLCommand.
select * from myTable where DataEdited > 'some hard coded date data'
I want to read the above 'some hard coded date data' from a table sitting in different database which is not the same server where the DataReader is connected.
How to do that?
I can populate the 'some hard coded date data' to a SSIS variable but do not know how to embed that in the SQL statement.
I am using a DataReader to read an ODBC Data Source.
Some of my dates are not valid. I would like to have the DataReader just treat the bad dates as Null. However I cannot seem to find a setting that will get me past the DataReader.
In SQL 2000 DTS I was able to use a script to skip the bad dates.
Please help because I don't want to have to run SQL 2000 DTS on SQL 2005.
the following is the code,....When i run this code I get "Invalid operation exception", Trying to read when no data is present, but the query returns result in query analyser...can anyone suggest what the problem is ... Connection is open and the query is simple select statement
SqlCommand myCommand = new SqlCommand(query,myConnection); myConnection.Open();
i have 2 database queries. One fetches data from a table and other according to first query result second query fetches record from another table both of these queries make use of datareader and while loop for inserting data to dropdownlist , but instead of that i want to add all my row fetched by second query store one by one in a dataset for some time .in simple words i want to insert datareader record one by one in dataset. i am using asp.net2.0,c#, Sql server 2000
hi, i have this code it gets the records from db i need to add the results of the datareader to a label but label control does not have a datasource property second problem is how to comma separate the results.with array? or what please help i need to show the results like this: record1,record2,record3Dim Conn As New SqlConnection(ConfigurationManager.ConnectionStrings("Conn").ConnectionString) Dim strSQL As StringDim dr As SqlDataReader Dim userID As Integer = Session("cmmLogonUserID") strSQL = "select id,extension from musicExt"Dim cmd As New SqlCommand()cmd = New SqlCommand(strSQL, Conn) Conn.Open() dr = cmd.ExecuteReader()
'txtMediaFormats.Text = dr ??????? ' ddlGenres.DataBind() ???????? Conn.Close()
Looking at the below code you can see that I have a separate Connection for each Insert Statement.'OPEN CONNECTION TO ESOSQL MyConnection = New SqlConnection("......") MyConnection.Open()
'check if there are existing charges for this person. The user must enter in atleast 1 charge before proceeding with arrest insert. MyCheck = New SqlCommand("SELECT * FROM ARREST_CHARGES WHERE ARRESTNO = '" & Session("uid") & "'", MyConnection) MyCheck.CommandType = CommandType.Text MyDataReader = MyCheck.ExecuteReader
If MyDataReader.HasRows Then
MyConnection1 = New SqlConnection("...") MyConnection1.Open()
MyInsert = New SqlCommand("INSERT INTO ARREST_INDEX (ARRESTNO, NOTES) VALUES ('" & Session("uid") & "','" & tx_notes.Text & "')", MyConnection1)
Label1.Text = "" Else div1.Style.Add("display", "block") Label1.Text = "You must enter charges before proceeding." End If MyConnection.Close()One would think I should only have to use one connection. However, if I use only one I get this error:There is already an open DataReader associated with this Command which must be closed first. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.Source Error: Line 60: Line 61: MyInsert.CommandType = CommandType.Text Line 62: MyInsert.ExecuteNonQuery() Line 63: Line 64: ' MyConnection1.Close()The only way I could get rid of it was to encapsulate each individual INSERT statement within its own connection. This seems to me as very inefficient. Can anyone explain why I couldn't just use one connection?Thanks.
Hi... I made some code which is to return DataReader. And then I want to use it in other procedure. But I don't know how to extract value from Reader. Public Function GetMyProfile(ByVal uid As string) As SqlDataReader Using conn As New SqlConnection(ConnString) . . Dim Reader As SqlDataReader = cmd.ExecuteReader()Return Reader.RecordsAffectedcmd.Dispose()End UsingEnd Function Sub Button_Click() dim dr as SqlDataReader dr=GetMyProfile(ByVal uid As string) ....Is it right way ? End Sub