|
Well.. It's simple. Imagine that you have 2 combobox. One for city, other for street. You live in some especial city, so that's why the mayor part of your customers gonna be from that special city. So you store all street info for that city in the database, but someday you can be visited by customer from another city and you don't have information about that city. So you have 2 options: register every city in the world, with every street in your database (and you would have to get all that information every time from your database) or just permit to register new cities and streets (if they are not) in your database (method INSERT). So to do that i want to write in city combobox for example Boston, then i would like to check if Boston is already in the combobox, so i don't have to register it anymore or not. Because of structure of my application i created some arrayList for my combobox and assigned datasource, displaymember and valuemember. So i want to do a search only by displaymember of combobox (because i don't know valuemember) and if there is some item with same displaymember i want to get the valuemember of that item. Simple.
|
|
|
|
|
Why not use your database to store the new cities, then you don't need to worry about trying to search a combobox. If it's a new city then add to the database and refresh your combos through data binding. You also then have that city for the future. Same process with new streets should allow you to gradually build up the information that you need. txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Well... there is more troubles.. But doesn't matter. I already found good answer.
|
|
|
|
|
you've got a good answer; whether what you found is any good we will not know unless you tell us about it, what would be the decent way to end a thread anyway.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
Well.. It's more complicated, because i cann't just bind data to my combo. I need to do some operationes before, so i create an arrayList of combobox items and bind it. So before register customers data i make some check. 1st i check if combo.selectedValue is Nothing (=null) and if it is i call database procedure that give me id of my street (if it exists it gives me a real id, if it doesn't procedure inserts data and returns @@IDENTITY) than i check my DataSet if it has already that id and if it doesn't i add a row and get datasource of the combo (dim array as arraylist = combo.DataSource) and then add data to arraylist and than i have to reset datasource of my combo (combo.datasource = nothing combo.datasource = array). And then change combo.SelectedValue = sqlcmd.Parametres("id").Value.ToString() (i used it before and it didn't worked.. I spended some time searching and didn't found an answer. The problem was ToString() i didn't put it and it didn't worked that way).
By the way i found method i asked before FindExactString - searches for displayMember in a comboBox and FindString - searches for valueMember.
So.. It all works.. Simple but took some time. Tnx for trying to help =)
|
|
|
|
|
Hi
I've got a kind of complex windows application written in c#.
I want to save the whole application state to a file and reload it after a restart.
With application state i mean all objects of the application, text entered in forms, items in tree view etc.
Kind of method that saves the hole memory of the application.
How can i do that in an easy way?
Thanks
Adrian
|
|
|
|
|
There's no standard approach for that... It's very complex and sometimes impossible task. You will have to implement it by yourself.
Best wishes!Die Energie der Welt ist konstant. Die Entropie der Welt strebt einem Maximum zu.
|
|
|
|
|
adoerig wrote: How can i do that in an easy way?
There is no easy way.
The data must be persisted some how, must likely in adatabase. The application state itself, like window positions, sizes, etc. can be done with user settings but it will be up to you to set the cotnrols appropraitely on startup. I know the language. I've read a book. - _Madmatt
|
|
|
|
|
There is nothing that will do this.
All of the data you want to persist should be stored in data classes you've written for the purpose of holding this data so you do NOT have to rely on TextBox's and such to hold the data. Once you've rewritten your app to hold your app's data in proper storage classes, it's a simple matter of serializing those objects out to files and deserializing them back into those data objects when your app loads them the next time.
|
|
|
|
|
adoerig wrote: With application state i mean all objects of the application, text entered in forms, items in tree view etc.
Be carefull there; you'd reload the text in the form on the next application-start, as opposed to the data as present in the persistence-store. If that store is a multi-user database, chances are that someone alters the data and it would be different from what was "on screen" the last time.
adoerig wrote: How can i do that in an easy way?
Sounds like you want two things; caching data and saving state, am I right? It might make sense for form-positions, but I wouldn't serialize the contents of a memento.
An "easy" way would be to have a single class that represents the state of the form and it's contents. That would at least be easier than looping all controls and asking them for their internal state. Alternatively, you could mark classes or properties with custom attributes to identify them as 'having an internal state that needs to be persisted' and serialize the lot.I are Troll
|
|
|
|
|
I had the same problem a couple of years ago. It is really quite easy to do. Three steps:
1. Make sure that everything in your app is in a serializable hierarchy. This typically IS the case - your application is at the top of the hierarchy.
2. Make all handle-based references (files, streams, etc.) weak references. They should always check before they are used to see if they are null, then reopen if so.
3. Write that top element (the application) out to an Object stream. Then you can read that object stream back in to restore the session.
Number 1 above introduces a few twists. There are always certain values that you do not want to red back in. For instance: the aforementioned file handles/streams, current time, is something in an error state? For those values, make sure they are initialized and set them to non serializable.
It works well and it's fairly easy
|
|
|
|
|
i have a modem. vb.net 2008. I want to send sms to a mobile phone. Please can you assist?
|
|
|
|
|
This[^] may provide some assistance.Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
Hi to send SMS Using a modem you need to use AT Commands , AT Commands are the command that you need to send to the modem (GSM Modem ) and it will send the message to the required number , You can do a google search on "How to send SMS using AT commands"
Let me know if you need further help
Happy Coding-Regards
Bharat Jain
bharat.jain.nagpur@gmail.com
|
|
|
|
|
Hello,
I would like to ask if how will I edit existing database records
like the edit mode.
Any suggestion or comments are kindly appreciated.
Thanks,
dfan23
|
|
|
|
|
Are you serious? A very cursory search will turn up many results. Have you tried that? I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hello,
Sorry for bothering you but I am just asking.
This is a forum and I just post so that I can get
idea's.
|
|
|
|
|
It is expected that one does some research first. Even a modicum of such research would have yielded you a plethora of resources to answer the question yourself and perhaps learn in the process. Not doing any research and expecting to be given the answers is a waste of everyone's time and disrespectful to those who freely give their time here. I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Do you want to edit the data which you insert\add????If that is than the ans is
<br />
try <br />
con.open()<br />
Dim str As String = "update details set name='" & TextBox1.Text & "', address='" & TextBox2.Text & "', marks='" & Textbox.Text & "' where roll='" & Combobox1.Text & "'"<br />
cmd = New OleDb.OleDbCommand(str, con)<br />
cmd.ExecuteNonQuery()<br />
MsgBox("Record updated", MsgBoxStyle.Information, "Update")<br />
<br />
Catch ex As Exception<br />
MsgBox(ex.ToString)<br />
Finally<br />
con.Close()<br />
End Try<br />
|
|
|
|
|
This most certainly NOT the answer.
One, you have responded to the wrong post.
Two, you are excepting direct, unvalidated input from user controls that can, and will, expose you to sql injection attacks and other nasty results.
Three, it's VB I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi
I am looking for open source c# ide which i don't have to install. I just have open work and save my files and close the ide. Can u recommend me such an ide?
|
|
|
|
|
I'm running SharpDevelop[^] from USB, works like a charm I are Troll
|
|
|
|
|
|
I have SharpDevelop installed but didn't know about this feature. Thanks. Kevin
|
|
|
|
|
hi.....
how to read a file from a remote computer in any drive in C#...
some suggest to use UNC path, but i dont have any idea about it.
could somebody help me with an example of it.
|
|
|
|