|
Perhaps it is not the field "MortgageNumber" that is in error, but the drCustomersSearch that is. You should do a check after this statement:
drCustomersSearch = dtCustomersUpdate.Rows.Find(txtSearch.Text)
To make sure that drCustomersSearch actually found something. Perhaps that was the problem. Hope this helps.
|
|
|
|
|
Thanks for the quick response kschuler
This line of code: If drCustomersSearch("MortgageNumber") Is DBNull.Value Then is where the error occurs. That line is testing to see if the PK (MortgageNumer) of the table (NamesandAddress) is available. The goal is to have it come back null when there is no record, but instead I get the NullReferenceExc. The search works fine when you use a valid MortgageNumber, but for some reason it can't return a row with nulls. Am I missing something to be able to handle a row with nulls? Again thanks for the response.
Nathan Lindleyy, .NET Aficionado
|
|
|
|
|
I didn't think anything else was required to be able to check if something was DBNull.Value. I would try debugging. Put a break point on that statement and see what value is says drCustomersSearch("MortgageNumber") really is...then check what just drCustomersSearch's value is...If that doesn't shed some light on it, you might want to put the whole thing in a try block and in the catch portion put a messagebox to display the exception's message. Sometimes they have better error message there. Sorry I can't be more helpful.
|
|
|
|
|
Thanks again Kschuler.
I did the debugging and the values for the drCustomersSearch comes back as Nothing. I guess when it cant find the row it returns Nothing as the value. I did a check for Nothing, but still got the NullReferenceException. Not sure how to work around this. Might have to rethink the whole approach.
Nathan Lindley, .NET Aficionado
|
|
|
|
|
When you say that you are checking for nothing, are you checking just the DataRow object? I think your code should look something like this:
dtCustomersUpdate = DsNameandAddress.Tables.Item("NameandAddress")
drCustomersSearch = dtCustomersUpdate.Rows.Find(txtSearch.Text)
If drCustomersSearch Is Nothing Then
MessageBox.Show("Customer could not be found.")
Else
If drCustomersSearch("MortgageNumber") Is DBNull.Value Then
MessageBox.Show("Your entry is not a valid Mortgage number." & Chr(13) & Chr(13) & "Try search again.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
txtSearch.Focus()
txtMortgageNumber.Text = ""
Else : txtMortgageNumber.Text = drCustomersSearch("MortgageNumber")
End If
End If
|
|
|
|
|
The problem is you're trying to get the value of a row that doesn't exist. Since your call to dtCustomersUpdate.Rows.Find() returned Nothing , you have to check if drCustomersSearch is Nothing before you try and do anything with it.
drCustomersSearch = dtCustomersUpdate.Rows.Find(txtSearch.Text)
If Not drCustomersSearch Is Nothing Then
If drCustomersSearch("MortgageNumber") Is DBNull.Value Then
MessageBox.Show(blah, blah, blah)
txtSearch.Focus()
txtMortgageNumber.Text = ""
Else
txtMortgageNumber.Text = drCustomersSearch("MortgageNumber")
End If
Else
' The search didn't find anything, handle this case...
End If
It's standard practice to check to see if any object actually exists before you try and use it.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks Kschuler, Dave!
I had checked it for being Nothing before and was still getting the NullReference, but when i checked if Not Nothing, it seemed to do the trick. Thanks for the advice.
Nathan Lindley, .NET Aficionado
|
|
|
|
|
Hi all.
I'd search in the board how an can get text that is at the coordinate x,y (I have a flexgrid on external program and want to get the text of some row/column by its x,y coordinates).
I didn't found nothing. Can someone help me?
Please, help me.
Thx in advance.
Best Regards,
Marco Alves.
|
|
|
|
|
You can't. The control has to export the functionality to do that, and it doesn't. There is no Win32 API calls you can make to easily force the text out of the control.
An alternative would be to implement a kind of OCR (Optical Character Recognition) to read the text from a bitmap screenshot image.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
In C#, VB, Managed C++, or VC++?
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
In any language.
If it is not possible, how I can get number of rows of a msflexgrid of a external program?
|
|
|
|
|
See if this helps.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
i'm currently working on a program to capture a manually higlighted text/chars in AXwebbrowser object. is there any way that i could capture that event in run-time? if there's none. is there any alternative that i could use?
|
|
|
|
|
Kenneth Villasenor wrote: is there any way that i could capture that event in run-time
There is no such event exposed by the Browser control.
Kenneth Villasenor wrote: is there any alternative that i could use
AFAIK, the Browser control doesn't respond to WM_GETTEXT message the way you would expect it to. So, no, there is no alternative to it.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
aside from relying on the browser control. is there any way that i could handle the highlighted text and store it's value to a variable.
|
|
|
|
|
You just asked the exact same question you did in your original post. There's no way to get at that text, so there's no way to get it into a variable.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
I want to print multiple values in the same Parameter Field of Crystal Report. I fetch data from table in loop and assign it to a Parameter Field. My problem is that it overwrites the last value, I want it to Display as New Value for the same Parameter Field in a new row. I'm writing the sample code below to make it clear.
For count = 0 To 2
crReportDocument.SetParameterValue(0, "Amit" & CStr(count))
crReportDocument.SetParameterValue(1, count)
Next
Now for the Parameter Field 0 and 1, the value printed in report is
Amit 2 2
But I want my output to be
Amit0 0
Amit1 1
Amit2 2
My requirement is such that I cannot bind Crystal Report to a datasource.(pity). I have to define Parameter Field and supply values to them through the code.
An early reply or suggestion will be highly appreciated.
|
|
|
|
|
Hi
I created an application using vb.net,which logs the error in event viewer. This application is working well at XP and windows 2003. But at windows 2000, it is showing error. Can any1 please tell me, what are changes i need to make in the system or code, so as to execute it on windows 2000.
Thanks in advance
Manish
|
|
|
|
|
First, Windows 2000 has to have at least Service Pack 4 installed.
Next, check to make sure that the account your running your app under has sufficient rights to write to the event log.
Lastly, you might want to post the error message your getting when you run your app.
Oh!! There are no changes you have to make to your code, it should work already with no changes.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I have given Admin rights to internet user as well as ASPNET user.
I have also made changes in the registry of Event Log so as to allow guest.
Please let me know is there any solution for this.....
Thanks for your reply
Manish
|
|
|
|
|
The problem is, I don't know what you, or someone else, did to break it in the first place! This should be working by default!
Does the NETWORKSERVICE account have rights?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hello,
I've created a call reporting app using SQL Express edition as the local data source, and have packaged it up, and deployed it on another machine. Once I installed it on the other machine, the program runs fine, and I can see that my data has populated in some forms.
How do I gain access to those tables? After my app installed, I only see an executeable to launch the program, and cannot locate the tables with data in it anywhere.
Thanks in advance,
Rashar
|
|
|
|
|
Search the drive for *.MDF and *.LDF and you'll find it.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Please tell me that How One can rename, copy, delete, move etc a file already stored on one's hard drive by using the Visual Basic Program.
I am using Visual Basic 6.0
Mahtab Masood
|
|
|
|
|