|
As Alan has already mentioned, reading files from the same physical disk is usually slower. And to add to that, you may try reading data in chunks rather than reading the entire file at one go. It may not increase the "efficiency", but it may add to the responsiveness of your app.
|
|
|
|
|
Hi,
I am working on the C#/.NET application where in i need to get Current Identity value of the table using LINQ. Or else I can use the sql query to get the task done by either using
var num = DataContext.ExecuteCommand("Select IDENT_CURRENT ('table')");
By using this above code, i am getting the value = -1.
or
var num = DataContext.ExecuteQuery(("Select IDENT_CURRENT ('table')");
By using the above code, i am getting an exception "Specified cast is not valid." and the value remains NULL.
Correct me if i am doing something wrong. let me know if there are any better ways to do this task.
Thanks for ur help in advance.
|
|
|
|
|
First, you can't do it in LINQ.
Next, the bigger question is why are you getting the next IDENTITY value or a table?? What do you think you're going to do with that value?? This value isn't usable in a multi-user environment because it can change immediately after a client gets the value.
Whoops...I missed the DataContext part. You're supplying a single parameter when ExecuteQuery expects two of them at least. The first is the query (you've got that), the second is the type of the IEnumerable to return. In your case, that would probably be an Integer or Long?
|
|
|
|
|
Thanks for the reply.......
I will using the Current Identity value of the table in creation of folder with name as Current Identity value. is there a way to do this different it is not to be done in LINQ?
|
|
|
|
|
madhubabu wrote: is there a way to do this different it is not to be done in LINQ?
When he said you can't do it with LINQ, he meant with LINQ syntax (e.g., "FROM blah In context.SomeTable SELECT field" is LINQ). You should have no problem doing it with ExecuteQuery if you follow his advice and specify the return type (and follow my advice in the other thread and get the first item from the returned collection).
Driven to the ARMs by x86.
|
|
|
|
|
I am new to .net so my request may look silly.but here is my question...........
can i know what would be the return type and even how to extract the first value out of the collection for
var num = db.ExecuteQuery<"ReturnType">("Select Ident_current('[mers_testing].[dbo].[Repositories] as value')");
The Identity column in the database is of datatype smallint
Thanks in advance
|
|
|
|
|
You've still got a problem. Unless you return the ID number in the same sceop as the SQL INSERT you can get back the wrong ID number. Your SQL INSERT statement has to be followed by a SELECT SCOPE_IDENTITY(), like this in order to return the correct ID number:
INSERT INTO tablename (fields) VALUES (values);
SELECT SCOPE_IDENTITY() AS [LastIdentity];
It's better to do this as a stored procedure than to assemble it and use it with ExecuteQuery directly with this batch.
When your INSERT code runs, it'll automatically return the identity value that was assigned to back to you, without having to worry about another user screwing things up by inserting another record in the table between the first users trips to the database.
|
|
|
|
|
Dave Kreskowiak wrote: Next, the bigger question is why are you getting the next IDENTITY value or a table?
FYI, the OP wants the last identity value, not the next identity value.
Driven to the ARMs by x86.
|
|
|
|
|
Yeah, I messed up. The result is the same though. If he doesn't get the ID number back from the same scope the INSERT is in, he could get back the wrong ID number.
|
|
|
|
|
I am new to .net so my request may look silly.but here is my question...........
can i know what would be the return type and even how to extract the first value out of the collection for
var num = db.ExecuteQuery<"ReturnType">("Select Ident_current('[mers_testing].[dbo].[Repositories] as value')");
The Identity column in the database is of datatype smallint
Thanks in advance
|
|
|
|
|
You still cannot do this in a multi-user environment. You've been warned...
Buit, a smallint in SQL is a 16-bit signed integer having a range of -32768 to +32767.
In .NET, the equivilent type is a short . So, in place of the "ReturnType", you put short .
...dbExecute<short>("SELECT ...
|
|
|
|
|
thanks for the reply............it works.
|
|
|
|
|
Don't cross-post. For future reference, there is a LINQ forum.
Driven to the ARMs by x86.
|
|
|
|
|
Identities are evil, they cause nothing but trouble like you're experiencing now, don't use them.
|
|
|
|
|
Check my edited reply to your duplicate version of this question in Questions and Answers.
Short version - You can't do what you're trying to do the way you're trying to do it.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
I have small Windows Forms project.
And My DataGridView Query like the following manner:
string MyQuery1="select field1,field2,field3 from myTable"; Con.Open(); MySqlAdapter=New sqlAdapter(MyQuery1,con); MySqlAdapter.fill(MyTable); Con.Close(); DataGridview1.DataSource=MyTable; Now, my DataGridView's columns displaying like
Field1, Feidl2, Field3... good in English Mode...[Left to right]
But when My user changes his keyboard language this datagridview should display like the below manner...Is it possible?
Field3, Fiedl2, Field1 [Right to left]
Thanks && Regards
PARAMU
|
|
|
|
|
1) Format your code snippets using the "code block" toolbar item
A simple way would be to have another query with the field order reversed.
I know the language. I've read a book. - _Madmatt
modified on Wednesday, June 29, 2011 11:59 AM
|
|
|
|
|
This should work. I've just tried it and it seemed to do exactly what you wanted.
dataGridView1.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
|
|
|
|
|
My 1/2 tension get released.
Nice & Wonderful !!!
Thanks For The Helps...!
Thanks & Regards
PARAMU
|
|
|
|
|
Hello Everyone,
Sorry for putting this question in this board. I didn't find any broad for WCF.
I am trying to develop couple of Web Services (which I have done already in ASMX version)
Now as a reference and for development ease, I want to do this like:
domain.com/store.svc/Products?APIKEY={KEY}&ProductId={Id}
I searched a lot on WEB but unfortunately not able to find any resource which can help me with this.
I will be thankful to you all for any suggestions and pointers.
Thanks
Amit
|
|
|
|
|
logicon wrote: I didn't find any broad for WCF.
What about the one in the list to the left marked "WCF".
The best things in life are not things.
|
|
|
|
|
You maybe want to look in to RESTful services. See here[]as a starting point.
|
|
|
|
|
Here for a complete tutorial.
|
|
|
|
|
How can i convert a Datatable to a Multi line in C#??????Ihave a DataTable with Values,and i want now to convert all of them in a multi line Graph in C# my first Row have information with Date and time,and will be my X Axis, and the other Rows,will be my Y axis with Value of censor.
may be some one can help me
Thx in advance
|
|
|
|
|