Never mind guys, I got it - the bigint is of type decimal, I'm going to stick to int as it falls under my requirement range anyway. Don't know why I chose a damn bigint in the first place. Thanks for reading.
link_79
Posts
-
Execption in db command..please help -
custom metadata editor using c#.netThis may be useful - I got this error once for a completely different project (nothing related to yours) and it turned out that some of the dll's I had added a reference to had recently changed and I had an older copy. Say the new X.dll had a ftn call Y() and my lod X.dll did not contain the ftn Y(). Funny thing is the code compiled fine but at runtime it caused the exception you are getting. When I refreshed the dll, it worked fine. Hope this helps.
-
Execption in db command..please helpHi guys, below is a code snippet that is raising a cast exception when I attempt to pull out data from a row reader. // setup command = "SELECT IDENT_CURRENT ( @tableName )"; getLastIdentityCommand = new SqlCommand(command); getLastIdentityCommand.Parameters.Add("@tableName", SqlDbType.VarChar, 20); .... // in my prepare ftn routine , I set the connection and table name getLastIdentityCommand.Connection = con; getLastIdentityCommand.Parameters[0].Value = tableName; getLastIdentityCommand.Prepare(); ... // finally I use the damn thing elsewhere SqlDataReader rowReader = getLastIdentityCommand.ExecuteReader(); long lastInsertId = -1; // I was using 'int' before but problem still remains if (rowReader.Read()) lastInsertId = rowReader.GetInt64(0); // causes cast exception ... Things to NOTE: 1) A row is inserted into a table X with identity set - identity column is of type bigint, before the problematic db command is issued 2) I have even tried using the "SELECT @@identity" syntax in the select statement without a table name, and tried extracting the id generated as follows : int lastInsertId = (int)getLastIdentityCommand.ExecuteScalar(); 3) I have even tried rowReader.GetInt32(0); and still the same exception. Is an identity a special type and NOT and integer?? How can I get this value since I need to update a 2nd table with it. ANy and all help will be very appreciated. Thanks.
-
Thread lockingGeez, that solution was staring me in the face, but my internal bulb never went off.:doh: My doubts with the 'lock(this)', threw me off course.:laugh: Thanks for all the help guys.
-
Thread lockingThis definitely helps, thank so much. But then how can I ever do the following: If say a class 'Service' offers three services: Class Service { void Service1() { // modify x } void Service 2() { // modify y } void Service3() { // modify z } } and I there are 'n' number of threads, each wanting to do only 1 of these services. I want the ability to be able to only do 'method' locks, not lock the whole object meaning that services should be able to run simultaneously, becuase I know that these services modify different resources. No 2 thread should be able to enter the same service. C# only provides for lock(...) { } there is no syntax like lock // this block of code { } or is there? Thanks again.
-
Thread lockingHi all, I need some major clarification on the thread locking mechanism. This might be a bit long so please bear with me. Supposing we have a class definition as follows: Class X { private Y obj1; private Z obj2; public void Ftn1() { lock (this) // section 1 { obj1.ModifyThis(); } } public void Ftn2() { lock (obj2) // section 2 { obj2.ModifyMe(); } } public void Ftn3() { lock (this) // section 3 { obj2.ModifyMe(); } } } // main ftn. X mainObj; Thread A new ThreadStart(mainObj.Ftn1()); Thread B new ThreadStart(mainObj.Ftn2()); Thread C new ThreadStart(mainObj.Ftn3()); // start them all now My question are: Q1. Since Ftn1 has a 'lock(this)' code block, if thread 'A' started first, will 'B' and 'C' have to wait till 'A' is done (even though their jobs are to do ftn2 and ftn3. I ask this because, 'X' has been explicitly locked in the call to 'Ftn1', and 'Ftn2' and 'Ftn3' belong to this 'X'? Note: My current understanding is that the 'lock(this)' call is actually only locking that section of code i.e. only this method is locked, but the 'this' now has me confused and I need it cleared up before I proceed any further. Q2. If you look at Ftn2 and Ftn3, they lock different things, but acces the same resource, so my question is if Ftn2 fires first, then will all go well i.e. Ftn3 will have to wait till the lock on obj2 is released, but if ftn3 fires first, there is a possibility that obj2 will get a corrupted result but deadlock will never occur? If my assumptions are true then I can continue on with endless coding more satisfied and releived. Any other input or advice will also be very welcome. Thanks for reading.:)
-
MDI Child focus problem when button is disabledHi, A couple fo questions - + Is the button that is being disabled on the active form or another form? + Also you say the code jumps out of the OnClick handler, did you mean focus only but code executes fine. You might have to take the long way - write a diable event that returns focus to the 'current' mdi form window.
-
ColumnChanging event on DatasetHi, Typically in the empty column of a table, the value "(null)" is entered by default(for a data grid atleast) and that is probably why the null case is not being detected. You will probably need to put in a break point to see if the value being returned is indeeed "NULL" instead of "" like you expect. I haven't tested this myslef so I could be way off. Hope this helps.
-
Getting a - "Cannot implicitly convert type 'int' to 'byte'" error - Help!You are the Man. Thanks so much, doing this worked - newABC[i] = BitConverter.GetBytes(oldABC[p] ^ xyz[q])[0];
-
Getting a - "Cannot implicitly convert type 'int' to 'byte'" error - Help!Hi everybody, this is my first post so please bear with me. Ok here's what I am trying to do, and for the love of me I can't 'see' an implicit conversion happenning, so why the hell is the compiler whining??? here is a class skeleton, similar to what I have public class X { protected void ThisIsKillingMe(byte[] oldABC) { byte[] newABC = new byte[100]; // line below reports an implicit complier error newABC[i] = oldABC[p] ^ xyz[q]; } private static readonly byte[] xyz = {0x12, 0x5F, ....}; } Thanks for any and all help.