|
Sandeep Mewara wrote: This error happens when you try to use a property of an object that is null.
More details:
Or call a method on the object.
|
|
|
|
|
Yep, right. Thanks for adding it.
|
|
|
|
|
but I can't see where is the problem specially it's working fine my laptop when I connect to local and remote database.
here is the code:
private void populate_family_physician()
{
this.Cursor = Cursors.WaitCursor;
data_table = new DataTable();
sql_connection = new MySqlConnection(ConfigurationManager.ConnectionStrings["SQLdb"].ConnectionString);
sql_connection.Open();
sql_command = new MySqlCommand("sp_get_pricelist_by_code", sql_connection);
sql_command.CommandType = CommandType.StoredProcedure;
sql_command.Parameters.AddWithValue("param_pricelist_code", "FamilyPhysician").MySqlDbType = MySqlDbType.VarChar;
sql_adapter = new MySqlDataAdapter(sql_command);
sql_adapter.Fill(data_table);
dataFamilyPhysician.DataSource = null;
dataFamilyPhysician.ResetBindings();
dataFamilyPhysician.DataSource = data_table;
gridFamilyPhysician.Columns["price_list_id"].Caption = "price_list_id";
gridFamilyPhysician.Columns["price_list_id"].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
gridFamilyPhysician.Columns["price_list_id"].AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
gridFamilyPhysician.Columns["price_list_id"].Width = 80;
gridFamilyPhysician.Columns["price_list_id"].Visible = false;
gridFamilyPhysician.Columns["price_list_description"].Caption = "Description";
gridFamilyPhysician.Columns["price_list_description"].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Default;
gridFamilyPhysician.Columns["price_list_description"].AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Default;
gridFamilyPhysician.Columns["price_list_description"].Width = 150;
gridFamilyPhysician.Columns["price_list_price"].Caption = "Price";
gridFamilyPhysician.Columns["price_list_price"].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
gridFamilyPhysician.Columns["price_list_price"].AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
gridFamilyPhysician.Columns["price_list_price"].DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
gridFamilyPhysician.Columns["price_list_price"].DisplayFormat.FormatString = "#,###,##0.000";
gridFamilyPhysician.Columns["price_list_price"].Width = 50;
this.Cursor = Cursors.Default;
}
|
|
|
|
|
Is sql_connection defined properly?
Any specific reason you have this line of code: dataFamilyPhysician.ResetBindings(); ?
Rest looks fine as such.
If you are unable to debug it on your system then start writing logs after few lines to track the culprit.
|
|
|
|
|
Check that following variables are not null before using them:
- dataFamilyPhysician
- gridFamilyPhysician
- gridFamilyPhysician.Columns["price_list_id"]
- gridFamilyPhysician.Columns["price_list_description"]
- gridFamilyPhysician.Columns["price_list_price"]
|
|
|
|
|
Add some logging to your programs - that will help a lot when you try to find the cause of an error.
You could also use the *.pdb files - thus the line number where the error occured will be shown, and then it's generally easy to determine which of the objects involved was null.
From your function name, I guess that you want to fill a combobox/ listview with data from a list. Are you sure that that list is not null?
|
|
|
|
|
I found where is the problem guys..
The App.Config file was not deployed with the project.
I guess Microsoft error must be more clear in such case
Thanks everyone.
|
|
|
|
|
Hi you'll. I'm a newbie C# programmer. My project is to find unmatched records of two tables in sql database. The two tables are both transactions and i need to find the discrepancies. The columns include date,time,transaction ID and amount. I'm having difficulty because the tables are not identical, meaning both tables have extra column that I don;t need to match. What tools do I need to do this project. Please help.
|
|
|
|
|
First and foremost: Logic.
How do you define what an "unmatched" record is? What is the logic that determines this?
How many records are you going to "scan" through, worst case?
Once you have that, you can figure out what the best method is to approach this, and the "tools" you're going to need.
If you're talking about which designers you'r going to use, forget it. Write this entirely by hand. You'll have a much better understanding of what's going on.
|
|
|
|
|
I second what Dave said. You'll need to have two essential tools -- a way to sort the lists and a way to compare the items.
Once you have those, I suggest a MasterFileUpdater[^].
|
|
|
|
|
if this is an SQL database i think you should use SQL...
try adding a where clause to your query so it just returns the matching records...
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
Thanks for the reply guys!
I have two sql tables, bank and store transactions. Unmatched data are datas/transactions that didn't match. example :
table A
A B C D E
100 10 11/11/2011 10:20:00 12
102 11 12/12/2012 10:23:00 12
103 12 12/13/2012 10:50:00 12
105 51 12/12/2012 10:22:00 12
106 55 12/15/2012 10:55:00 12
table B
A B C D E
100 10 11/11/2011 13:20:00 12
102 11 12/12/2012 13:22:00 12
103 12 12/13/2012 13:50:00 12
105 51 12/12/2012 13:22:00 12
106 52 12/15/2012 13:55:00 12
I need to make a program that will show the unmatched record in column B. My project has about 300thou data's and also I need to adjust the time ' table A is in MT and Table B is in ET.
I'm not good in explanation so if it's still too vague feel free to ask for more information...
l.scott249@yahoo.com
|
|
|
|
|
In addition, if the records mismatched then show it. if they matched then ignore.
|
|
|
|
|
(i'm from Brazil, so MT and ET aren't so familiar to me, but I've searched...)
between ET and MT there are 2 hours of difference, so, you can add 2 hours to your time in ET to convert it to time in MT (if this is really necessary, please, verify) so, you can use the following select to get only the records that didn't match:
SELECT A.*, B.*
FROM A
INNER JOIN B
ON A.A = B.A
WHERE (A.B <> B.B
OR A.C <> B.C
OR DATEADD(hour, 2, A.D) <> B.D
OR A.E <> B.E)
as you can see, it's very simple, but i'm making a lot of assumptions here, i'm assuming that your tables have a relation (foreign key constraint), that the field "A" on the two tables is the id of the transaction, that table B uses time in MT and that you care about any differences
also, about times in different time zones, watch daylight saving time, this depends on the state that the time is saved, as a general warning, would be much better if your date and time were stored in UTC(so you don't need to care about time zones and DST) and in yyyy-MM-dd format.
if this didn't solve your problem, please, let me know, so i can try to help you again.
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
Thanks a lot, Sorry about the time confusion. I'll try this and I'll let you know if it works.
|
|
|
|
|
Is it possible not to write a code in SQl and instead do it visual studio? Also, the unmatched data output needs to be in PDF file and also in charts. Any idea on this?
|
|
|
|
|
yes, it's possible to write this code in C#, although, i can't think of a situation were you would like to bring all the data in the table to your application to do this, but if you really want, i suggest to take a read on the article that PIEBALDconsult indicated on this answer: http://www.codeproject.com/Messages/4250500/Re-finding-unmatched-record-data-in-two-sql-tables.aspx[^]
also, about PDF and charts, i can't help you on this, but are various articles in this site about this, i've made a rapid search: http://www.codeproject.com/search.aspx?q=write+pdf+tag%3aC%23&doctypeid=1%3b2%3b3&sort=ratingdesc[^]
i think this one is worthy a read: Gios PDF .NET library[^]
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
Thank you so much!You Rock! if you were here in US,I'd be taking you to lunch lol!
|
|
|
|
|
I don't think that would work. Surely an outer join is necessary?
Something like this:
SELECT A.*, B.*
FROM A
FULL OUTER JOIN B
ON A.A = B.A AND <OTHERS>
WHERE A.A IS NULL OR B.A IS NULL
|
|
|
|
|
the inner join is to take the correspondingly registries, that have the same key, in the "where" is where the actual matching is performed, verifing what fields of the table doesn't match. the id must always match, else, how do you know what transaction corresponds to what?
in your query you take the registries that don't have pair in the other table, what the op seems do seek is the registries that have pair, but with different values.
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
I was reading an article a few minutes ago here on CP that discussed how to host a Form designer. I do not have any particular use for it right now but I was curious. So I got it up and running, it works well and as expected. I began looking around on MSDN for the various things I could do with it, such as the various Service interfaces for the designer. Now I have run into a bit of an issue with one of these services.
I was looking for a way to be notified when a control has been added (via the IToolboxService I created). The only thing I can find, which may be the incorrect method and someone please tell me if so, is the IDesignerEventService. It has events like "ActiveDesignerChanged" and "DesignerCreated". So I figured I could hook the "DesignerCreated" event up and remove the IToolboxService when that event is fired. Here is how I did it:
IDesignerEventService evt = designSurface.GetService(typeof(IDesignerEventService)) as IDesignerEventService;
if (evt != null)
evt.DesignerCreated += new DesignerEventHandler(evt_DesignerCreated);
However, "evt" ALWAYS has a 'null' value, therefore never being able to receive the desired event. Anyone have an idea why this is happening? I have hooked up other events with no problem but this one is being a PITA.
Thanks in advance!
------------------
SOLUTION:
As far as receiving events, I went with Pete's advice and I implemented "IComponentChangeEvent". In order to load/save the form design I was able to "decipher" the article I was reading. This is the article on MSDN. I am close to completing my little test that I have been working on in order to learn more about the subject. Thanks again!
djj55: Nice but may have a permission problem
Pete O'Hanlon: He has my permission to run it.
modified 14-May-12 19:46pm.
|
|
|
|
|
OK, a couple of things here. First of all, you really should get the design service from IDesignerHost service. Basically, this is responsible for the lifetime management of designers, so is the appropriate place to get an instance of a designer from.
Now, onto the point of what you are trying to do. You actually need IComponentChangeService if you want to find when a component has been added or removed to the designer surface. Have a look at this[^].
|
|
|
|
|
Thank you for the information. That is what I was looking for. I appreciate it!
How about key press events on the designer? I have gone to Google for this as well, though with no luck.
EDIT:
Nevermind, I figured it out. I simply handled the "KeyDown" even of the application form and it works perfectly. Thank you for your help!
djj55: Nice but may have a permission problem
Pete O'Hanlon: He has my permission to run it.
modified 14-May-12 13:05pm.
|
|
|
|
|
Excellent. Congratulations on this. The VS object model is a bit of a bitch to work with.
|
|
|
|
|
Yeah, that has become quite apparent in the past few weeks for me. I've been messing with a lot of it out of curiosity. Haha.
djj55: Nice but may have a permission problem
Pete O'Hanlon: He has my permission to run it.
|
|
|
|