|
Thank you for your reply
First, I've no doubt that ADO .NET is much better than MS Access
But, the only thing that I want to implement is that to make my program read only the record that I'm viewing currently on the form (or may be read no more than 5 records in order to decrease the number of reads to the database server).
What's the easiest method for implementing this?
BTW, using the SqlCommand while limiting the number of records is not the thing that I want, for example, if I use it to read 10 rows only, then only those rows will be displayed in the form, and this is not correct in my case...
|
|
|
|
|
fifothekid wrote: the only thing that I want to implement is that to make my program read only the record that I'm viewing currently on the form
This depends how you bind the data to your controls, but lets concentrate on the data fetching from the db only. If you for example want to get the data for customer which has ID equal to 5, you could have something like:
using (SqlConnection connection = new SqlConnection(connectionString)) {
SqlCommand command = new SqlCommand("SELECT * Customer WHERE ID = @Id", connection);
command.Parameters.AddWithValue("@ID", 5);
connection.Open();
SqlDataReader reader = command.ExecuteReader();
reader.Read();
...
It would perhaps be easier to use SqlDataAdapter and fill a datatable which then again is bound to the controls in the form.
fifothekid wrote: using the SqlCommand while limiting the number of records is not the thing that I want, for example, if I use it to read 10 rows only, then only those rows will be displayed in the form, and this is not correct in my case
I don't know which kind of UI structure you have in mind. If you have somekind of list of for example customers in your app, you would get the list first. When selecting from the list, you would fetch that customer only to a new form. Fetching the list and fetching the individual customer are separate operations and would most likely be implemented differently. If you fetch all the customers with all their fields to the list and pass the row to the form, you would end up to problems exactly like you described.
|
|
|
|
|
Hi i have a table with three columns
col1 col2 Result
1 4 null
2 2 null
8 3 null
6 5 null
Now i want to add col1 & col2 and insert in to column "result"
the ouput should be like this
col1 col2 Result
1 4 5
2 2 4
8 3 11
6 5 11
How to write query for this in sqlserver?
G. Satish
|
|
|
|
|
I guess its another homework question, but just for once....
update yourtablename
set Result = col1 + col2
and please buy a sql book before posting any more questions like this, its more of an insult than a question.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
modified on Friday, January 9, 2009 10:18 AM
|
|
|
|
|
Just curious, was the formula in the statement intentional?
|
|
|
|
|
Whoops! Now correct - damned shift key
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
That's one good feature in Finnish keyboards, plus and equal characters are on different keys. So, my version of the statement is: update yourtablename set Result 0 col1 ? col2 . See, much clearer
|
|
|
|
|
So it is. Maybe I should emigrate to Finland - on second thoughts, it's too cold
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Nooo, it's not cold at all. Last night it was only -15 degrees Celsius.
|
|
|
|
|
Positivey tropical then
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Yeah
|
|
|
|
|
Ok, now I know why you are on the boards so much, step outside and freeze your [insert relevant anatomical part] off.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
That could be one reason
Must admit that without emoticons it was kinda hard to say whether your post was or
|
|
|
|
|
said with humour and respect. I do find it a bit frustrating coming in and looking for something to answer and seeing your moniker after most of the questions and knowing the asker has already got a solution. The MVP was well deserved.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks, I really appreciate your comments!
Don't worry, I've had some extra time over the last few days but the situation is going to change Thinking afterwards I may have been a bit too eager to answer the posts.
By the way, I have few article ideas in mind and especially one of them requires a bit more work. Since I've never wrote an article with another person I think it would be interesting to do so and I believe that at least I would learn a lot from the process as well as the technologies used. Would you be interested in participating? If you are, I think we could have more conversation via email.
|
|
|
|
|
hello all,
My application in windows C#. i have two database in sql server 2005.
i want to insert record in both database but the major concern is that if any one failed its transaction then it should rollback both trasaction in both databases.
please guide me for this.....
Amit Agarwal
|
|
|
|
|
Amit Agarrwal wrote: want to insert record in both database but the major concern is that if any one failed its transaction then it should rollback both trasaction in both databases
This is called distributed transaction where you have a special coordinator which takes care of the transactions. The transactions themselves are ended using two-phase commit.
You could start here: http://msdn.microsoft.com/en-us/library/ms191440.aspx[^]
A slightly different variation is using Linked Servers.
Amit Agarrwal wrote: i have two database in sql server 2005
Just wondering what that actually means. If you have two different SQL Server instances, then you need to distribute the transaction (one way or another), but if you have two different databases inside a single SQL Server instance, you can use normal transactions.
|
|
|
|
|
What Free Database Software supports Multiple Platform PC Databases with Network Hub Update Exchanging for Records?
I will approximately 12 HP Desktop PC's.
Duo Core 3.0 GHZ 2 GB RAM 500 GB Hard Drive.
Each PC will have its own local FREE database.
When any individual database changes, either all of the other databases must be updated slowly or one dedicated SUPERVISOR PC Database has to contain all the records and updates fro the others.
Any Suggestions for FREE or LOW COST SOLUTIONS?
Please Help.
BC
|
|
|
|
|
|
Which will work easiest for the Configuaration I have and the Pc's I have and Windows XP Professional on each and having to update recors of all the individuals between them or to one Supervisor PC Database?
Regards
BC
|
|
|
|
|
I wouldn't know an answer for that. Most of the products I've used are usually commercial. Possibly each products website provide you more information for your case.
If all the workstations are Windows-based, I would consider SQL Server Express and Sync Framework for the data trasnfer, but I admit, my opinion is a bit biased.
|
|
|
|
|
I am trying to make SQL Server Express 2008 and Sync Framework for the data transfer work as my first choice as well. I too have only used commercial licensed versions of Database Software over the past 20 years. But the customer is always right and they want FREE. I hope I can make this configuration work.
Regards
BC
|
|
|
|
|
Do you have the Link for the Fre version of Sync Framework?
Regards
BC
|
|
|
|
|
|