Hai Guys, I have a doubt Regarding SqlDataReader i can able to create object to Sqlconnection,Sqlcomand etc... but i am unable to create object for SqlDataReader ? Logically i understand that SqldataReader a way of reading a forward-only stream of rows from a SQL Server database. This class cannot be inherited. sqlDatareader belongs to which class is it sealed or static class? can we create own class like SqldataReader ....... Reply Me ...... if any one know the answer..............
I'm using Delphi 2006 to create a DLL which will be integrated into SQL 2005. It's been a long road and I've made a lot of headway, however I am currently having the following problem creating the stored procedure:
My dll name is 'Crystal_Reports_Test_01' In the DLL, my class is named 'Class01'. In the DLL, my procedure is named 'TestMe'
I've managed to integrate the DLL into SQL using the following statement:
CREATE ASSEMBLY TEST_ERIC_01 AUTHORIZATION dbo FROM 'c:mssqlassembliescrystalreports.dll' WITH PERMISSION_SET = UNSAFE
I am attempting to create the stored procedure which points to the 'TestMe' method inside of the DLL. FYI: 'CrystalReports' is the namespace above my class that I had to add in order to get it to locate the class. The following code is used to create the stored procedure:
create procedure dbo.Crystal_Reports_Test_01( @Parm1 nvarchar(255) ) as external name TEST_ERIC_01.[CrystalReports.Class01].TestMe
But I get the following error:
Msg 6573, Level 16, State 1, Procedure Crystal_Reports_Test_01, Line 1Method, property or field 'TestMe' of class 'CrystalReports.Class01' in assembly 'CrystalReports' is not static.
I'm not sure what this means exactly. I think it means the method (the procedure) is not using Static method binding but should be. I have no idea what this really means or how to accomplish this in the DLL - or if I'm even going about this in the right way.
Any help would be appreciated ! I'll post the Delphi code (DLL) below.
Thanks,
Eric Gooden
library CrystalReports;uses System.Reflection, System.Runtime.InteropServices;...................type Class01 = class public procedure TestMe([MarshalAs(UnmanagedType.LPWStr)] var sVarString: wideString); export; end;procedure Class01.TestMe([MarshalAs(UnmanagedType.LPWStr)] var sVarString: wideString); export;begin sVarString:= 'Lets change the value and see if the stored proc. gets the change.';end;end.
Hello there I'm having a little issue with Updating a SQL Table. *Deep Breath* OK, lets begin from the start... I Have a Table Called Job. I've an ASP Page setup to insert a new record into the Job table via a DetailsView Control with an SQLDataSource bound to it. This table has many columns in it, 4 of which are DateTime columns. I use a calendar Control from the toolbox for the DateTime selection and bound all the Calender control's SelectedDate to: SelectedDate='<%# Bind('EnteredDate') %>' using the EnteredDate field as my example. I only insert DateTime Values into 2 of the 4 DateTime columns in the original INSERT, so the remaining 2 columns are NULL. I have an UPDATE setup on a different page to edit the previously inserted rows in job using another SQLDataSource again using the bind method for calendars: '<%# Bind('RevisedDate') %>' My Problem is (according to this post I found online http://www.thescripts.com/forum/thread529052.html ) the page crashes with "Specified cast is not valid". The reason being I'm trying to bind to the remaining 2 NULL DateTime columns in an attempt to update them with a value my user will not be able to insert in the original INSERT. The solution Code I found on the link above is in VisualBasic and I have had little luck in trying to convert it into C# to even see if it solves my problem: VB Code: Function FixDBNull(ByVal inVal As Object) As DateTime If inVal Is DBNull.Value Then Return DateTime.Now Else Return inVal End IfEnd Function ASP Code: <asp:calendar id="calEditRevisedDate" runat="server"selecteddaystyle-backcolor="red"selecteddate='<%#FixDBNull(eval("RevisedDate")) %>'visibledate='<%# FixDBNull( eval("RevisedDate")) %>'selectorstyle-backcolor="Green"></asp:calendar> Any suggestions or work arounds would be greatly appreciated Thank You
Hi,the stored procedure returns only the first letter of the ouput parameter i.e 'e'. Actually It must return 'error while updating data'. can anybody helpme to solve this issue.How to set the size of output parameter.spvr_ErrorDescription='error while updating data which I get from the output parameter of stored procedure. How to set the size of output parameter in dataaccess layer. Below is the actual code.public string UserCostCenter_Upd(string spvp_Offering,string spvp_UserId,string spvp_CostCenter,DateTime spvp_StartDate,DateTime spvp_ExpiryDate,ref string spvr_ErrorDescription){// The instance ds will hold the result set obtained from the DataRequestDataSet ds = new DataSet();RequestParameter[] parms = new RequestParameter[7];parms[0] = new RequestParameter("@Return_Value", DbType.Int32, ParameterDirection.ReturnValue, null, true);parms[1] = new RequestParameter("@p_Offering", DbType.AnsiString);parms[1].Value = spvp_Offering;parms[2] = new RequestParameter("@p_UserId", DbType.AnsiStringFixedLength);if (spvp_UserId == null)parms[2].Value = DBNull.Value;elseparms[2].Value = spvp_UserId;parms[3] = new RequestParameter("@p_CostCenter", DbType.AnsiString);if (spvp_CostCenter == null)parms[3].Value = DBNull.Value;elseparms[3].Value = spvp_CostCenter;parms[4] = new RequestParameter("@p_StartDate", DbType.DateTime);if (spvp_StartDate == null)parms[4].Value = DBNull.Value;elseparms[4].Value = spvp_StartDate;parms[5] = new RequestParameter("@p_ExpiryDate", DbType.DateTime);if (spvp_ExpiryDate == null)parms[5].Value = DBNull.Value;elseparms[5].Value = spvp_ExpiryDate;parms[6] = new RequestParameter("@r_ErrorDescription", DbType.String, ParameterDirection.InputOutput , null, true);parms[6].Value = spvr_ErrorDescription;// Create an instance of DataSQLClientAirProducts.GlobalIT.Framework.DataAccess.DataSqlClient daSQL = new DataSqlClient(Constants.ApplicationName); ;// typDSRef holds the ref. to the strongly typed datasetDataSet typDSRef = (DataSet)ds;DataSet resultDataSet = daSQL.ExecuteDataSet("[ap_UserCostCenter_Upd]", ref parms);// Call DataHelper.MapResultSet function for mapping the result set obtained in ordinary DataSet to strongly typed DataSetDataHelper helper = new DataHelper();if (!helper.MapResultSet(ref typDSRef, resultDataSet))ds = null; // Returns a null reference if the DataHelper.MapResultSet is failed. //returnCode = (int)parms[0].Value;spvr_ErrorDescription = (string)((parms[6].Value == DBNull.Value) ? null : parms[6].Value);return spvr_ErrorDescription ;}
Hi everybody,I need to understand how concurrency excatly work in asp.net. For example, I'm confused what happens if two users at the same time try to access the same record in a table or even the same variable. Do ASP.NET handle this , I mean by locking one user and letting the other to have access OR it's up to the programmer to write some code to lock shared resources such as database , objects and variables?If it's up to the programmer to do this task, I appreciate if you can show me an example that clarifies that.Thank you
Following on from a thread I started about "concurrency" (real-time-ishsystem), I thought I would play about to see if I could easily adapt my datamodel to take account of potential multi-user write conflicts. So, I wouldappreciate you checking my logic/reasoning to see if this kind of thingwill work. Below I have a stored procedure that will simply delete a givenrecord from a given table. I have appended a "_Written" counter to thecolumns of the table. Every time the record is written, the counter isincremented. Clients store the current _Written count in their objects andpass this in to any write procedure executed.The procedure explicitly checks the _Written count within the transaction tosee if it agress with the written count passed in by the client. If it doesnot, the client throws an error. Note I am explicitly checking the_Written count precisely so I can determine exactly why this operation mightfail, rather than checking @@ROWCOUNT after an update.Thanks.RobinCREATE PROCEDURE dbo.proc_DS_Remove_DataSet@_In_ID INTEGER,@_In_Written INTEGERASDECLARE @Error INTEGERDECLARE @WRITTEN INTEGERBEGIN TRANSACTIONSET @Error = @@ERRORIF @Error = 0BEGINSELECT @WRITTEN = _Written FROM MyTable WHERE ID = @_In_IDSET @Error = @@ERRORIF @WRITTEN <> @_In_WrittenBEGINRAISERROR ('10', 16, 1)SET @Error = @@ERRORENDENDIF @Error = 0BEGINDELETE FROM MyTable WHERE ID = @_In_IDSET @Error = @@ERRORENDIF @Error = 0COMMIT TRANSACTIONELSEROLLBACK TRANSACTIONRETURN @Error
Do single commands (or stored procedures) execute concurrently, or they are executed one by one. How do you perform a lock during the execution of a command (or stored procedure).
I have a user object that is stored in the session for each user but what if an administrator updates a certain user and I want to reflect the update to the user if they are logged in?One possible way of solving this is:Each time the user goes to a page, check the user table and compare the timestamp. That would mean if 30 users refresh the page..the db would hit 30 times lol. I don't think that would scale very well.Any ideas on how to solve this?
I have a table where I count how many emails of a given type are sent out each day. This incrementing is wrapped in a sproc that either inserts a new row, or updates the existing row. The column that counts the value is named Count of type INT. Below is the sproc, seems like a straightforward thing. However, I'm seeing email counts higher than they should be when there's a high number of concurrent executions of the sproc. I'm pretty sure it's not a problem in the calling code, so I'm wondering about the UPDATE statement, since it updates a column based on the value of the column. I would think this should work since it's wrapped in a SERIALIZABLE transaction, anybody have further insight? SQL Server 2005 by the way. Sean CREATE PROCEDURE [dbo].[IncrementEmailCounter]( @siteId SMALLINT, @messageType VARCHAR(20), @day SMALLDATETIME) ASBEGIN SET NOCOUNT ON; SET TRANSACTION ISOLATION LEVEL SERIALIZABLE BEGIN TRANSACTION IF (SELECT COUNT(*) FROM EmailCount WHERE SiteId = @siteId AND MessageType = @messageType AND [Day] = @day) = 0 INSERT INTO EmailCount (SiteId, MessageType, [Day], [Count]) VALUES (@siteId, @messageType, @day, 1) ELSE UPDATE EmailCount SET [Count] = [Count] + 1 WHERE SiteId = @siteId AND MessageType = @messageType AND [Day] = @day COMMIT TRANSACTION SET TRANSACTION ISOLATION LEVEL READ COMMITTEDEND
I'm wondering whether the following code would work if users are RAPIDLY registering (assumption) WITH the same username.public bool UsernamExists(string username) { string sql = "SELECT true FROM [users] WEHRE username = @username;"; return Convert.ToBoolean(comm.ExecuteScalar()); }
//update or insert sql for user etc blah blah } If two users try to signup AT THE VERY SAME TIME (DOWN TO THE NANOSECOND), would this technique work? Do I have to wrap it in a transaction, stored procedure?? Thanks.
Hi,I'm trying to implement Optimistic Concurrency in asp 2 but so far it has caused me nothing but problems.First, when doing an UPDATE I tried to use the primary key & a timestamp field which I had in SQL Express.. VS 2005 generated the stored procedures fine however when it came to the actual updating I think there was a problem with the conversion of the timestamp field when it was being stored in a text box (in a FormView control). So.. as a result that failed. And also I checked sooo many places online and haven't been able to find any examples of code where a timestamp was used with success in asp2.Next, I got ride of the timestamp type (in SQL Express database) and used a datetime and then.. I just implemented Optimistic Concurrency by passing in ALL the values (ie all the original values) like is proposed http://www.asp.net/learn/dataaccess/tutorial21vb.aspx?tabid=63 . This... works however I really do not want to have to pass in ALL these values (ie original and new).Ideally I would like to be able to use the primary key & the datetime field to handle the Optimistic Concurrency checks where only the original values of both those fields are passed back into the stored procedure. Now.. I tried this as well, but I kept getting an error that suggests that (for some reason) the FormView or DataSource is passing ALL the values (original & new) into the dataset as opposed to only the original primary key & datetime fields & the new set of values.Can ANYONE offer any help? I really would like not to have to pass in all these values.Thanks in advance!
Hi! I'm building a web application with ASP.NET, and using MS SQL 2000 for my database server. How should I do to guarantee the integrity of the data in spite of the concurrent access? Meaning... how can I make sure that more than 1 user can update 1 table at the same time, while no error will occur? Do I need to add some codes at my aspx file? Or do I need to do something to my database? Or do I not have to worry about it? Thank you.
Can anyone help with concurrency issues. Small network and only one person at a time can log into the database. It was originally written in MS Access and converted to SQL 7.0 with a VB front end.
Is there any way to get the sample below working so that both "threads" are guaranteed to get unique and incrementing values?
I'm suspecting the answer is no. You can use transactions on completely database oriented operations that read/write to a database and complete. But there aren't complete synchronization controls for operations like below that try to return a value to an outside process.
IF OBJECT_ID('SimpleTable') IS NOT NULL DROP TABLE SimpleTable
CREATE TABLE SimpleTable ( A INTEGER ) INSERT INTO SimpleTable (A) VALUES (1)
-- Run in one window DECLARE @value INTEGER
BEGIN TRANSACTION SELECT TOP 1 @value = A FROM SimpleTable WAITFOR DELAY '00:00:05' UPDATE SimpleTable SET A = @value + 1 COMMIT TRANSACTION
SELECT @value SELECT A FROM SimpleTable
-- Run in a second window DECLARE @value INTEGER
BEGIN TRANSACTION SELECT TOP 1 @value = A FROM SimpleTable UPDATE SimpleTable SET A = @value + 1 COMMIT TRANSACTION
Did I understand correctly the Pesimistic access: When we choose pessimistic access -we lock all the rows of the table. right. -other users still can access the table if they specify read only mode meaning if their intention is to only read the data and not modify it. am I right
In a previous post, the theme of cursors and concurrency was touched as a secondary subject. I have a specific question about it as the primary one:
if we have -------- create proc myProc as declare cursor for select * from mytable go ---------- if two or more clients(webpages for example) execute myProc concurrently will the cursor be safe ? or would I have to make special arrangements, there are a couple of procs (that use cursors)that somebody else did and would not like to modify but we want to make the procs web available,
hi gurusthe scenarioFrontend - MS Access (not yet decided whether MDB or ADP)Backend - MS SQL Serverit is a conversion from MS Access backend to MS SQL Server Backend.Planning to create stored procedures for all the Inserts, Updates,Deletes and Business Rules / Validations wherever it is possible.the problemi am running in concurrency problem. the same classic scenario of twousers retrieving the same row (record) from the same table. it allowsboth the user to update the record, that is, the user who updates lasthas his changes saved though he retrieved that particular recordsecond.what i need is that the user who retrieved the record second shouldn'tbe able to update or delete the record when it is already retrieved byany other user.would appreciate if someone pointed me in the right direction to solvethe above problem, i know it is related to isolation property but amnot surethanx in advanceregardsbala
Hi, I was wondering if it is possible to call a stored procedure from sql server 2005 (call it sp_1) that calls an assembly which takes a message, wraps it in soap and calls a webservice and waits for a reply from that webservice (the stored procedure is clr not t-sql). This WebService needs to then call sp_1 to perform some other tasks. Is this possible or does sp_1 need to have finished what it was doing before it can be called again.
I have been trying to do this and have received a number of errors one of which looks like;
'The context connection is already in use.'
Sorry if I haven't worded it very well, I will try to clear up any questions if you need me to.
I want to centralize my previous standalone application. Previous application was using VB.NET and Access XP. Now I want to keep a centralized database (SQL Server 2005) and VB.NET 2005. At this point of time thousands of concurrent users will connect to the database at the same time.
In my application, when a ticket is being issued to a tourist, an SQL query finds the max(ticketno) for the current month from the main table and reserves this number for the current ticket. When the operator has finished entering information and clicks SAVE button, the record is saved to the main table with this ticket no. Previously there was no issue since the database was standalone.
I want to know how to block the new ticket no so that other concurrent users are not using the same number for saving a record. How to better tune the database for thousands of concurrent users at the same time? I also want that the other user must not get an error message when he attempts to save a record. It should be automatically handled by the database.
I created an ETL Process which loads four different types of files into different tables in parallel. There is no issue with this parallelism as the sources and destinations are distinct. But I have a common log table where I log the status and timings of each load for any file type. When ever I start a new file load, I create an entry in this log table with the FileTypeID and LoadInProcess as 1 (this will be set to 0 for all other records of the same file type). At different stages of the load, I will pull the active LoadID of the current file type and update the same record with the timings and results. My code looks like this -
Code Snippet SELECT
@LoadLogKey = LoadLogKey FROM
SystemLoadLog (NOLOCK) WHERE
FileTypeID = 1 and LoadInProcess = 1
IF @LoadLogKey is NULL
RAISERROR('Unable to retrive LoadLogKey for the current load!')
Process1Result = x, Process2Result = y, Process3Result =z WHERE
LoadLogKey = @LoadLogKey
The first SELECT query is giving problems as different processes are using the same table to log the results and timings. The source files I load are too small that the data load finished in 1 or 2 seconds most of the time and within this timespan, I update the log atleast 10 times. So, if four different file types are loading, the hits to the SystemLoadLog can be as bad as 20 to 30 times in 1 second.
There are 17 Client PC connected to a Server with SQLExpress 2005.
17 Client will do verification of identity before sending data to display at server in first in first out basis using Datagridview ( the earliest data received will be
display first) and stored for review at later stages.
What should I do? I plan to use VB2005 after trying the EXpress.The Tasks are simple:
Data send --> Server Diplay and Stored---> Someone at Server will Acknowledge by
Button--> Messages will be sent to inform Client data received.
I could have 17 different Table (But with same fields!) and displaying the Data send by reading all 17 tables and display it with Datagriedview. But this definately will
be slower than Just read from 1 table!
I'm concerned about Concurrency as there is chances that May be more than 1 user
might trying to update the Database at the same occasion. Can someone provide me a
Tips and advice?
Note: I had came across something call CurrencyManager which is related to
I have the following stored procedure... CREATE Procedure UserGetInfo2 (@UserID int, @SystemTimePeriodID int )As set nocount onSELECT Users.UserId as UserID, Users.UserName as UserName, Users.RealName as RealName, UserTimePeriod.BudgetCode as BudgetCode, UserTimePeriod.SystemTimePeriodID as SystemTimePeriodID, Users.Password as Password, Users.SSN as SSN, Users.Location as Location, Users.ScheduleType as ScheduleType, Users.EmployeeType as EmployeeType, Users.TimeAccounted as TimeAccountedFROM Users INNER JOIN UserTimePeriod ON Users.UserId = UserTimePeriod.UserIDWHERE (users.userID= @UserID) AND (UserTimePeriod.SystemTimePeriodID = @SystemTimePeriodID)returnGO The problem lies in that when a person has a SystemTimePeriodID over a certain value, there is no UserTimePeriod record since it has not been created yet. Obviously, I need to wrap this in an IF...EXISTS IF EXISTS (SELECT UserTimePeriodID FROM UserTimePeriod WHERE (SystemTimePeriodID = @SystemTimePeriodID) AND (UserID = @UserID)) (the SELECT above, since that's what needs to come back if the data exists) ELSE Do the same select but put in a static value for BudgetCode, like '0000' GO How could I do the part where the IF...EXISTS fails? I'm... not sure I can use RETURNS, since it feeds into this recordset: rstUserInfo2.Open "UserGetInfo2 " & Request("UserID") & ", " & Request("SYSTIMEPERIODID") and later uses values from that RecordSet, such as <td><%=rstUserInfo("BudgetCode") & ""%></td>
I'm attemping to deploy a crypto class that we use on a desktop app to SQL Server. I'll use the encryptstring/decryptstring found in this class as User Defined Functions on SQL Server. When I try to deploy the class I'm getting this error:
Error 1 Method, property or field 'EncryptString' of class 'EncryptingDecryptingOASISPWDS.Crypto' in assembly 'EncryptingDecryptingOASISPWDS' is not static. EncryptingDecryptingOASISPWDS
I have a number of SqlDataSource objects in my application, which don't have Optimistic Concurrency option enabled. The SDS objects use custom Sql statements so I can no longer select the Advance button to enable Concurrent Concurrency. How can I enable this option? Is there a designt ime property, and even a run time property that can be set? The only method we have so far is to create a new SDS, with Optimistic Concurrency switched on, then copy and paste my custom Sql into it and rebind my components.. Any help on this matter is appreciated. Regards, Steven
i'm dealing with Concurrency Issue in SQL Server 2005,
let me explain me what i want to do
I have a table
UserInfromation
ID (PK - Int autogenerated )
Name ( Varchar(20) )
Age ( int )
LastModifiedDateTime
User 'A' inserts a record in UserInformation Table
1 John 20 12/12/2005 15:30 PM
i have written Stored Procedure which Get's the records from UserInformation Table
again i have one more stored Procedure which updates the UserInformation already entered in UserInfromation Table
if User 'A' runs the Get StoredProcedure on his machine and binds the Dataset ( result ) to GridView at 10:00 AM
A User 'B' runs the Get Stored Procedure on his machine and binds the DataSet ( Result ) to GridView at 10:01 AM
both users are looking at the same same data which was entered by User 'A'
now User 'A' Updates the Record (i.e)
1 John 20 12/12/2005 15:30 PM
to
1 Kemp 50 12/12/2005 10:05 PM
at 12/12/2005 10:05 PM
but the User 'B' is still looking at the data which contains
1 John 20 12/12/2005 15:30 PM
which means the data is invalid,
so my question is how User 'B' is goin to get the notification that the data which he is currently seeing is old one and someone else has modified the data
To solve this problem i have a LastModifiedDateTime Column in UserInformation table which keeps the record of when this data( row ) was modified
what i do is when i get the data from my get stored procedure i get all the columns from the Table and when i modify the selected record i pass the required information in Input Parameter ie. ID ,UserName ,Age , LastModifiedDateTime ( this is the datetime which was saved when the particular record was modified ) , now i'm using the LastModifiedDateTime value and comparing it with the same ID's record.
e.g.
while Running the Get Stored Procedure i'm getting
1 John 20 12/12/2005 15:30 PM
when i'm executing Update Procedure i'm passing values as
1 Kemp 50 12/12/2005 15:30 PM
in my update Stored Procedure i'm comparing the Passed date 12/12/2005 15:30 PM with the current value in the same Id's i.e. ID = 1 LastModifiedDateTime Column if the date which is passed by the user as input parameter is different then the passed ID's LastModifiedDateTime columns value then the stored Procedure will raise and error that the "Data has been changed , request user to Refresh the Data"
my Question is , Is there any other way that i can implement concurrency issue in SQL Server 2005 . Please let me know