|
No dude, not yet
still am researching
no one providing necessary things.
|
|
|
|
|
Hello. I have a listview where I load data from sql database. ListView has two columns (name, surname) where data is loaded. On the selectedindexchanged event, when an item from the listview is selected it gets the other data from the database, based on selection, and writes it to several textboxes... basicly a phonebook. If I select someone from the list the info is displayed in the txtboxes, but if i click smeone a second time i get an exception "NullRefferenceException" "Object reference not set to an instance of an object."
private void lvNameList_SelectedIndexChanged(object sender, EventArgs e)
{
ClearSearch();
select = "SELECT * FROM agenda_telefonica WHERE nume = '" + lvNameList.FocusedItem.Text + "' AND prenume = '" + lvNameList.FocusedItem.SubItems[1].Text + "'";
SqlDataReader dr = realSql.Select(select);
if (!dr.HasRows)
{
MessageBox.Show("Information not found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
while (dr.Read())
{
tbName.Text = dr[1].ToString().Trim() + " " + dr[2].ToString().Trim();
tbPhoneNumber1.Text = dr[3].ToString().Trim();
tbPhoneNumber2.Text = dr[4].ToString().Trim();
tbPhoneNumber3.Text = dr[5].ToString().Trim();
tbFaxNumber.Text = dr[6].ToString().Trim();
tbEmail.Text = dr[7].ToString().Trim();
tbCompany.Text = dr[8].ToString().Trim();
tbService.Text = dr[9].ToString().Trim();
tbEquipment.Text = dr[10].ToString().Trim();
}
}
dr.Close();
realSql.Close();
}
}
The exception is raised the second time i click an item in the list and points to the select string. Does it have something to do with the FocusedItem?
|
|
|
|
|
Before doing anything else check the if the SelectedItems.Count property is > 0.
|
|
|
|
|
Thanks.
|
|
|
|
|
You are closing realSql which is not opened in the method you have posted. It could therefore be realSql (null after closing) that is causing the exception.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
realSql is a dll refference to a sql class i've created. it has an select(string select) which open an sql connection then returns a datareader ("SqlDataReader dr = realSql.Select(select)"). So the realSql.Close() closes the connection opened by the Select() method.
|
|
|
|
|
i have to Make a GridView with print option (Inherit the GridView control and add a print method). The print button should print all the rows in the gridview. There should an option to print no of rows perpage.
. i have to use GDI printing APIs for printing.
Maifs
|
|
|
|
|
So, get started - you'll finish quicker that way!
Was there a question you wanted to ask?
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
When faced with a problem like this, you have to ask yourself a question.
"Am I so brilliant that I have thought of doing something so extraordinary that no one has thought of doing it before?"
In 999,999,999 cases out of 1,000,000,000 cases the answer is going to be NO.
If the answer is yes, ask here. In all other cases Google the bloody thing!!!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
can you tell me that which type of quesiotns have to be asked here?
its a realy so pythetic answer.
Maifs
|
|
|
|
|
The sort of questions that should be asked here are those concerning a piece of code that you have written, that is not working in the way you expect, or at all. This is CodeProject.
The important points to remember here are
a) code
b) you have written
There are so many solutions to this problem on the internet that people are reluctant to answer, because it is perceived (may not be true but it is perceived) that you are too lazy to either Google, or try for yourself.
Find something on the Internet that most nearly suits your situation and try to implement it. If you get stuck then or do not understand part of it then ask here with a code snippet that is relevant (properly formatted, of course) and any error messages.
For goodness sake Google for print datagrid c# or print datagridview c# whichever applies. Pick one and have a go.
All of this advice is free, there is no need to thank me!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi,
I want to decompile a CHM file (help file) and also be able to compile the generated files back to a CHM file again in C#.
I have tried to do this using Microsoft Html Help Workshop. I create a Process and decompile with hh.exe and it works fine. After that I create a Microsoft Html Help Workshop project file, and the project file works perfect if I compile in Microsoft Html Help Workshop. But if I create a Process in .Net and try to compile with hhc.exe I get a corrupt CHM file, it looks like a web page that not can be loaded. I got the same problem if I compile from command line -> hhc [project file].
HHC5013: Error:
runtime error R6002
- floating point not loaded
Is it possible to do this only in C#? Or anyone who knows what is wrong?
I have added Hh.exe and Hha.dll in my Path variable.
I am not sure where I shall post this question so I try here.
Best regards
Marc
|
|
|
|
|
Hello,
Digging up this post from 1000 years ago
I am experiencing the issue of R6002 floating point not loading while running hhc.exe from the command line.
Have you by any chance found how to solve this issue (and remember how?)
Thanks
|
|
|
|
|
I don't think you should expect any response from the OP. It looks like his last activity on CP was 11 years ago. I very much doubt that he will read your reply / follow-up question.
Religious freedom is the freedom to say that two plus two make five.
|
|
|
|
|
How will I validate the text of email address. I am making a window application in c# .net, in the text box I want that the textbox of email contains the '@' without written @ it gives a messagebox that it is not valid email address.
thanx in advance
|
|
|
|
|
Use a regular expression. There are several examples of email validation on google - some more accurate than others, so take your time and read around the various implementations (i.e. look for ones that can handle more complex email addresses such as .museum addresses).
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
The best way of doing this is using Regex. Try the below code.
private void txtboxEmailAdd_Validating(object sender, CancelEventArgs e)
{
string pattern = @"^[a-z][a-z|0-9|]*([_][a-z|0-9]+)*
([.][a-z|0-9]+([_][a-z|0-9]+)*)?@[a-z][a-z|0-9|]*\.([a-z][a-z|0-9]*(\.[a-z][a-z|0-9]*)?)$";
System.Text.RegularExpressions.Match match =
Regex.Match(txtboxEmailAdd.Text.Trim(), pattern, RegexOptions.IgnoreCase);
if (match.Success || txtboxEmailAdd.Text == "")
return;
else
MessageBox.Show("Invalid Email Address" + "\r\n" + "Please enter Valid Email", "Invalid Email Error",MessageBoxButtons.OK, MessageBoxIcon.Error);
e.Cancel = false;
}
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Didn't read the question properly!
string s = "Hello@email.com";
if (s.IndexOf("@") <= 0)
{
MessageBox.Show("Not an EMAIL address");
}
This will report on @email.com and email.com, but not on a@email.com
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
This is not a workable solution. What happens if the user enters @me, or bob@bob, or ¬¬¬@¬¬¬?
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Agreed it is not the complete solution - it covers the @me case since the indexof returns 0 - but I didn't want to confuse him too much, just answer the question as asked. A regular expression would work better, but I guess the "proper" solution would be to interface to Outlook (or express, or whatever) and check the entered address against his contacts list - ouch!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Have a look at the RegEx Expression I gave him. It caters for all the validation, checks on the domain etc etc and that there is a valid name@something.com etc. I think I added a check in that there are no spaces in the email address either. I think it is pretty comprehensive in what it checks. Even if I have to say so myself....
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Kwagga wrote: Even if I have to say so myself....
Smartass - your code earns you a perma link as I'm certain to need this sometime in the future! Thanks
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
NO worries mate. Glad I could help 1 person today.....
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
The original RFC regex is (as follows):
(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\]) It's not perfect, but is a starting point.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
In datagridview how will I make a validation for the length of text written in cell, eg. mobile no column takes on 10 digits
|
|
|
|