|
Hi,
I am getting the this error :Object Reference not set to an instance.
when i debug i came to know that 'qry' is not initialized.Bui have initialized it.Don't Know why 'qry' is not getting initialized.
my code is:
Dim rdoSex As String
Dim CreateDate As String
Dim qry as String
Dim i As Integer
CreateDate = Now.Date.ToString()
If rdoMale.Checked = True Then
rdoSex = "M"
ElseIf rdoFemale.Checked = True Then
rdoSex = "F"
Else
rdoSex = "NA"
End If
Try
qry = ""
qry = "insert into T_STU_MASTER values('" &CreateDate & "','" & txtStudentName.Text.Trim() & "','" & txtFatherName.Text.Trim() & "','" & txtMotherName.Text.Trim() & "','" & rdoSex & "','" & dtpDOB.Text.Trim() & "','" & cmbVillage.SelectedItem.ToString().Trim() & "')"
cmd = New SqlCommand(qry, con)
'//Error is thrown in above line that qry is null while i have initialized it
i = cmd.ExecuteNonQuery()
If i > 0 Then
MsgBox("Information Saved Successfully!!!")
End If
Catch ex As Exception
MsgBox(ex.ToString())
Finally
con.Close()
End Try
|
|
|
|
|
As far as I can see, that's not possible.
Are you absolutely certain that it's not the con variable that isn't initialised?
devsheoran wrote: Urgent Please help
It's never urgent enough to mention in the subject.
Despite everything, the person most likely to be fooling you next is yourself.
modified on Tuesday, March 11, 2008 4:39 PM
|
|
|
|
|
Are you *certain* ? Although this is pretty terrible code, I don't see any way that qry could be uninitialised. Try stepping through with the debugger and checking variable values, I think it's con that is null, it's the only thing I can not see initialisation code for.
You need to read this[^]. You also need not to initialise variables over and over ( you set qry to "", then in the next line, change it ). Also, rdoSex is not a radio button. Hungarian notation is not generally used nowadays anyhow, but that's just wrong.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
can somebody help me. i made a project that compose of many forms., in the 2nd form, it has timer that has only 30 min. and it will stop if 30 minutes is over. But if the 30 minutes is not yet over and i already reach the last form which is form10, the timer in the 2nd form should stop and the 2nd form will be hide. How can i do it?
the project that i am making is an IQ test, and it has many pages, when the test is answered already, the timer should stop..
can somebody please help me about my problem.. thanks!
|
|
|
|
|
You end up with 10 forms visible ? Sounds like you really want a wizard type interface.
Use delegates to get form10 to tell form2 that the timer is no longer required, and to make that form hide.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
no, the other forms will not be visible. the only visible form is the 2nd form, the form that has timer.
how to use delegates? can you tell me the codes for it?
|
|
|
|
|
I don't understand completely:
If all of these forms are in the same application then why don't you have form10 call form2's timer
and tell it to stop.
|
|
|
|
|
I am using the create user wizzard on my asp.net page. Can i specify which database users are added to and can i give users the ablilty to update details. can any one help me please.
Many thanks
|
|
|
|
|
This is better asked on the ASP.NET forum.
I have no idea, I don't use any of the built in wizards, I write my own code.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
hi all,
How would one go about replacing a character in a string with a space where the character is not in the range of a-z or A-Z or 0-9 ???
the following Code did not have the planned outcome...
Dim cleanString As String = [String].Empty<br />
Dim reg As New Text.RegularExpressions.Regex("[A-Z]|[a-z]|[0-9]")<br />
Dim coll As Text.RegularExpressions.MatchCollection = reg.Matches(LineText, )<br />
For i As Integer = 0 To LineText.Length - 1<br />
MsgBox(coll(i).Value)<br />
If (coll(i).Value = [String].Empty) Then<br />
cleanString = cleanString + " "<br />
Else<br />
cleanString = cleanString + coll(i).Value<br />
End If<br />
Next
the result was not pritty.... it removed spaces as well... how do i keep spaces and replace (NOT REMOVE) other characters with a space???
Thank you in advance.
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Try using the Regex.Replace[^] function.
Scott.
—In just two days, tomorrow will be yesterday.
—Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines] [ Articles] [ Blog]
|
|
|
|
|
With a single line of code:
Dim cleanString = Regex.Replace(LineText, "[^A-Za-z\d ]", " ")
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
If e.KeyCode = Keys.F1 Then
'MsgBox("F1 pressed")
AxWindowsMediaPlayer1.URL = "E:\iva_megh\audio\welcome.wav"
Play()
Do While AxWindowsMediaPlayer1.status <> "Stopped" And Timer1.Enabled And Not bInterrupted
Application.DoEvents()
Loop
End If
Sorry do not know how to continue the thread. Please inform me.
Thank you for all the efforts!
|
|
|
|
|
meghanaVishwa wrote: Sorry do not know how to continue the thread. Please inform me.
When viewing the message you want to reply to, simply click the "reply" link and write the new message. It will automatically be appended to the thread with the appropriate indenting level based on the message to which you were replying.
Scott.
—In just two days, tomorrow will be yesterday.
—Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines] [ Articles] [ Blog]
|
|
|
|
|
meghanaVishwa wrote: Do While AxWindowsMediaPlayer1.status <> "Stopped" And Timer1.Enabled And Not bInterrupted
Application.DoEvents()
Why is this not a complete waste of code ? I don't see what it could possible achieve?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
i have written it but the control is not going there when i debug it
|
|
|
|
|
yeah, great. why don't you use the thread you already started?
what did you write?
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|
|
Hi,
I beleive this sample code is in C#:
string cleanString = String.Empty;<br />
Regex reg = new Regex("[A-Z]|[a-z]");<br />
MatchCollection coll = reg.Matches(<mystringgoeshere>);<br />
for(int i = 0; i < coll.Count; i++)<br />
{<br />
cleanString = cleanString + coll[i].Value;<br />
}</mystringgoeshere>
See, i want to remove all characters that do not fall in the A-Z or a-z OR 0-9 category AND replace it with a space...
example test123t3er = test t er
Am i wrong in saying that the Regex reg = Regex("[A-Z]|[a-z]") CAN IT BE: Regex reg = Regex("[A-Z]|[a-z]|[0-9]") ???
AND the cleanString = cleanString + coll[i].Value;
CAN I DO A TEST: IF(coll[i].Value == String.Empty) THEN cleanString = cleanString + " " ELSE cleanString = cleanString + coll[i].Value ???? - in this way i add space if the character is not in the above category????
So please help me convert the very top section of code and i will build from there...
Thank you in advance...
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
(via Instant VB):
Dim cleanString As String = String.Empty
Dim reg As New Regex("[A-Z]|[a-z]")
Dim coll As MatchCollection = reg.Matches()
For i As Integer = 0 To coll.Count - 1
cleanString = cleanString & coll(i).Value
Next i
David Anton
http://www.tangiblesoftwaresolutions.com
C++ to C# Converter
C++ to VB Converter
C++ to Java Converter
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: convert VB, C#, or Java to C++/CLI
Java to VB & C# Converter: convert Java to VB or C#
|
|
|
|
|
Hi All,
Please help me!
I have windows media player 9.0 control on the form. The audio should be played on click of a particular button from the keys present in the keyboard. How do I know when the key is pressed? How to get the key pressed event?
Bye
Megh
modified on Tuesday, March 11, 2008 9:53 AM
|
|
|
|
|
meghanaVishwa wrote: How to get the key pressed event?
The same way you get all other events: Select the control for which you want to insert an event on the left combobox above your code-window, then choose the event from the combobox on the right hand side.
meghanaVishwa wrote: How do I know when the key is pressed?
If e.keycode = YourKey then...
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|
|
i want to pass the integer parameter fields to Crystal Report through .net 2003.i want in windows application.
|
|
|
|
|
i want to become incredibly rich without having to do any more work for the rest of my life.
(btw, it's urgent!)
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|
|
Here[^]
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi,
I’m trying to create the following Datalist in vb.net in the code behind window. I want to create the items in code rather than in the designer as I want to avoid an image placeholder appearing on the webpage if the value in the database is null.
Does anyone have a complete example they could share please?
<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl='<%# Eval("prod_image", "~/images/{0}") %>'/><br />
</ItemTemplate>
</asp:DataList>
Thanks,
Nick.
|
|
|
|