|
OK people I am a hack programmer - think of me as the homer simpson of programming
See my code below and please help me eliminate the "Null reference exception" warning/error I get..
Thanks I know this is a easy and i am a d*mb one
Public Overloads Function LoadOrdersData() As Data.DataSet
Dim sqlConn As New SqlConnection(ConfigurationManager.ConnectionStrings("SqlConn3").ConnectionString)
Dim sqlDa As New SqlDataAdapter("spBackOrders", sqlConn)
Dim sqlDs As New Data.DataSet
sqlDa.SelectCommand.CommandType = Data.CommandType.StoredProcedure
sqlDa.SelectCommand.Parameters.AddWithValue("@Customer", Session("CustCode"))
sqlDa.SelectCommand.Parameters.AddWithValue("@Customer2", Session("CustCode2"))
Try
sqlConn.Open()
sqlDa.Fill(sqlDs)
sqlConn.Close()
Return sqlDs
Catch
Finally
If sqlConn.State = Data.ConnectionState.Open Then
sqlConn.Close()
End If
End Try
End Function
|
|
|
|
|
thedom2 wrote: think of me as the homer simpson of programming
ROTFL !!!
thedom2 wrote: If sqlConn.State = Data.ConnectionState.Open Then
Given the rest is in a try catch I'd say you need to check if sqlConn is equal to nothing before checking it's properties. You should also put a message box in the catch to tell you the error, b/c if this is it, you won't be done, the code does not work. Probably because the connection fails, I would think,
Christian Graus
Please read this if you don't understand the answer I've given you
"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 )
|
|
|
|
|
There's a path where nothing will get returned. If you return something in the Catch block (or even Return Nothing ) or after the End Try you won't get that warning.
|
|
|
|
|
Wow - VB.NET still pulls crap like that ? What a disaster....
Christian Graus
Please read this if you don't understand the answer I've given you
"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 )
|
|
|
|
|
Unfortunately, yes. It reminds me of this gem from MSDN[^]:
The code in a Finally block runs after a Return statement in a Try or Catch block is encountered, but before that Return statement executes. In this situation, a Return statement in the Finally block executes before the initial Return statement. This gives a different return value. To prevent this potentially confusing situation, avoid using Return statements in Finally blocks.
(Modified because I didn't do the quoting right.)
modified on Tuesday, June 10, 2008 11:17 AM
|
|
|
|
|
thanks everyone doh!
|
|
|
|
|
Hi,
I was trying to implement Still Image in my VB.NET app, but I can't figure out how. I followed a lot of pages and discussions on the Internet, but I couldn't manage to get my app registered correctly.
Is there someone that has already faced this situation and can give me some advice?
Thank you
Matteo Rossi
|
|
|
|
|
what is the code to read data from.csv file in vb.net
|
|
|
|
|
I guess this means you are trolling. If you are, get a life. IF you're not, get serious. Buy a book, read the guide on how to ask sensible questions, and generally try to show some signs of being able to think for yourself. How is tell me a viable subject line ? I assume the question you asked just under here is the same one, although it's hard to tell without a real subject line.
Christian Graus
Please read this if you don't understand the answer I've given you
"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 )
|
|
|
|
|
ruthvik (AKA chaitu22), it seems that you are expecting us to do your homework.
As it appears that you have joined simply to plagiarise, I think it would be useful to both you and us if you did some research yourself and removed yourself completely from The Code project.
Troft not lest ye be sponned on the nurg! (Milligan)
|
|
|
|
|
what is the code for getting the information of firstname,lastname,dob,married of the .csv file in vb.netin vs2005
|
|
|
|
|
Do some work yourself and ask specific questions instead of asking others to do all your work for you.
|
|
|
|
|
Try Google.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
You may want to read the article I link to in my sig ( that is, the link in this message ). And, for heavens sake, buy a book.
Christian Graus
Please read this if you don't understand the answer I've given you
"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 )
|
|
|
|
|
Software environment :
VB6.0 SP6, sql server 2000, windows XP SP3. I have used components like datagrid..,crystal reports
"runtime error 6149 invalid bookmark". This is the error i get from the vb application.
Does anyhow know the reason or causes for the runtime error .?
can anyone suggest whats the possibility of this error?? and how to correct the error.
thanks in advance
|
|
|
|
|
Good Afternoon noor siraj
Technology is Something that should make things Simpler for us, not the other way round. You see Microsoft Saw that Vb6 was Rubish , and am Still Suprise that there are people who Still initiating Development and Spenidng time choosing between Languages and Come up with VB6, this is Getting Serious People. If you are a CEO or Project Manager or Developer who loves VB6 , then you should now start thinking about the Future of your Company and your Own Career as a developer.
"VB6 Is Dead, Why use VB6 while there is .NET"
If you ask Microsoft that Question , they will just ignore your Thread
Move to .NET
Hope it helps
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
How i can capture the image of a receiver into a vb.net program
How i can begin
Please help
Assaf
|
|
|
|
|
What is a reciever ? What do you mean by image, a bitmap, or a serialised version ?
You can begin by making your question clear.
Christian Graus
Please read this if you don't understand the answer I've given you
"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.
How can I schedule some audio files for playing in background.For example something like Task Scheduler in windows
for daily,weekly,... playing of audio files.
thank you.
|
|
|
|
|
You can schedule a task to play the audio file using the Windows Task Manager with this class library[^].
|
|
|
|
|
|
hi
can any one write the coding to view the particular view control in one form on click of the button in another form..through response.redirect method
spriya
|
|
|
|
|
I can. Why did you ask this here, when it's an ASP.NET question ?
( you pass values on the URL to change how the page is shown by default )
Christian Graus
Please read this if you don't understand the answer I've given you
"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'm absolutly sorry .i need the coding in vb.net. i have wrongly chosen asp.net . i have got the solution and also i cant get statement u hav sent. pls explain it clearly
spriya
|
|
|
|
|
Hi,
I developed a windows application in Vb.Net 2003.It is working fine in this.
But when I am trying to convert this into .Net 2005 I am getting this error.
Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
at System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(Guid& clsid, Object punkOuter, Int32 context, Guid& iid)
at System.Windows.Forms.AxHost.CreateWithoutLicense(Guid clsid)
at System.Windows.Forms.AxHost.CreateInstanceCore(Guid clsid)
at System.Windows.Forms.AxHost.CreateInstance()
at System.Windows.Forms.AxHost.GetOcxCreate()
at System.Windows.Forms.AxHost.set_Site(ISite value)
at System.ComponentModel.Container.Add(IComponent component, String name)
at System.ComponentModel.Design.DesignerHost.Add(IComponent component, String name)
at System.ComponentModel.Design.DesignerHost.System.ComponentModel.Design.IDesignerHost.CreateComponent(Type componentType, String name)
at System.ComponentModel.Design.Serialization.DesignerSerializationManager.CreateInstance(Type type, ICollection arguments, String name, Boolean addToContainer)
at System.ComponentModel.Design.Serialization.DesignerSerializationManager.System.ComponentModel.Design.Serialization.IDesignerSerializationManager.CreateInstance(Type type, ICollection arguments, String name, Boolean addToContainer)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeInstance(IDesignerSerializationManager manager, Type type, Object[] parameters, String name, Boolean addToContainer)
at System.ComponentModel.Design.Serialization.ComponentCodeDomSerializer.DeserializeInstance(IDesignerSerializationManager manager, Type type, Object[] parameters, String name, Boolean addToContainer)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression)
at System.ComponentModel.Design.Serialization.CodeDomSerializer.DeserializeStatementToInstance(IDesignerSerializationManager manager, CodeStatement statement)
at System.ComponentModel.Design.Serialization.CodeDomSerializer.Deserialize(IDesignerSerializationManager manager, Object codeObject)
at System.Windows.Forms.Design.ControlCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, Object codeObject)
at System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.DeserializeName(IDesignerSerializationManager manager, String name, CodeStatementCollection statements)
I am seeing a lot of people reporting this error, on other forums, but no one has an answer
Please anyone help me how to resolve this problem.
Regards
Pavani.
|
|
|
|