|
Well, unless it's another copy/paste error, you should space out your &'s
wrong:
MsgBox "Blubb"& i &"bla"
right:
MsgBox "Blubb" & i & "bla"
|
|
|
|
|
okay, thank you
but the error is still comming
it have to be the loop, cause i now only have
For i = 0 To 20 Step 1.0
Next i
and the error is still comming
modified 19-Feb-16 6:45am.
|
|
|
|
|
Well try setting the "step" to just 1 rather than 1.0
Presumably you have defined that as an Integer?
And you can remove the final i after Next.
|
|
|
|
|
i just ignor the step, it doesnt matter if it says "step 1" or nothing, 1 is the default value
|
|
|
|
|
So now you're saying
For i = 0 To 20
Next i
is giving you an error? I don't think so... unless you have not defined the variable i at all.
|
|
|
|
|
This:
Dim i as Integer
for i = 0 To 20
Next
or this
Dim i
for i = 0 To 20
Next
is showing the error
|
|
|
|
|
Well, the first will - you don't DIM variables with the As [type] in VBS. You could try
Dim i%
but other than that, and capitalizing the F in for, which shouldn't really be necessary, I really find it hard to believe that this is where the error really lies.
You need to pin down the exact line.....
|
|
|
|
|
The key point you are missing here is that it is not actually the same error!
If I paste your original code into t1.vbs I get the following error
C:\Temp\t1.vbs(3, 6) Microsoft VBScript compilation error: Expected end of statement Removing the i after the Next fixes that problem (as suggested by @Wombaticus)
If I do the same thing with your first block of code above I getC:\Temp\t1.vbs(1, 7) Microsoft VBScript compilation error: Expected end of statement ...getting rid of the as Integer fixes that one (as suggested by @Wombaticus)
Your second block of code above does not produce anything - neither error nor output. If you were getting an error there are you sure you remembered to save the changes in your editor before attempting to run the script file? We've all done that a few times
However, to get to the point ... See those numbers in brackets in my error messages above that are in bold? They indicate the ROW and COLUMN that the error occurs in - so the error moved from line 3 in the first example to line 1 in the second. Much easier to find the problem when you know that little bit of extra infomation
|
|
|
|
|
Thank you very much....
i don't even know what the error was. I had to restart the server, and now it works without doing anything
but thank you
|
|
|
|
|
|
i just looked at this, but i do not find a mistake in my code
|
|
|
|
|
Look at the Next statement, it does not use the variable name.
|
|
|
|
|
oh thankyou but that wasnt the error at all
|
|
|
|
|
Yes it was. When I removed the i from the Next statement it worked correctly. I can only assume you are doing something different to what you posted.
|
|
|
|
|
No "i" after "next".
For i = 0 To 10 Step 1
MsgBox "Blubb" & i & "bla"
Next works for me
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Beat me to it by a couple of minutes!
|
|
|
|
|
I have a program that has an associated SQL Server database, running in SQL Server Express 2014 all running on a virtual Windows 2008 server. The program has masses of different calls to the database to select, insert and update data through all sorts of different parts of the program. It has background workers threads running multi threading and it's all working beautifully.
But I have a procedure that's not a background thread that also has various calls to the SQL Server database and I'm finding that at around 1:50am every day this process is stopping (the background threads continue to function perfectly, it doesn't stop them) and when I log into the server there is a pop up box saying there was an issue connecting to the server. It's had a few different errors, a common one being "...an error occurred during the pre-login handshake". Click okay on the box and it gets back to processing as normal.
It's not the error that concerns me, it's the fact that nothing I do seems to catch the error and stop it popping up the error box. Nowhere else in the program is this a problem, everywhere else handles the errors fine and the code here is exactly the same as everywhere else. I have searched everywhere and can't find any posts with a similar error, so I'm posting my own.
Here is my code:
Try
Using conn = New SqlConnection(Gdetails.sConnectionString)
conn.Open()
Dim data As SqlDataReader
Dim adapter As New SqlDataAdapter
Dim command As New SqlCommand
command.CommandText = query
command.Connection = conn
adapter.SelectCommand = command
data = command.ExecuteReader()
While data.Read
If data.HasRows = True Then
End If
End While
End Using
Catch ex As Exception
Write_To_Event_Log(Environment.MachineName & " thread monitor error - " & " - " & ex.Message.ToString, EventLogEntryType.Error, 205)
End Try
I would think the try..catch should catch the SQL connection error and simply write the error to the event log. But it's not catching the error, it's popping up a message which might be okay for a user based system but is no good for something that's designed to just keep processing without user intervention.
It's like the SQL connection isn't treating this as an error, it's just popping up a messagebox of it's own, rather than actually raising an error that can get caught by the try..catch code, but I can't find anyway to tell it not to do that.
Help please!
|
|
|
|
|
I've never seen anything like that in any version of .NET, and I doubt there's any code in the SqlClient classes to pop up a message box. If there was, it would be a major bug that would have been discovered and widely reported by now.
What does the Write_To_Event_Log method look like?
Is there any code executing when you access Gdetails.sConnectionString ?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Gdetails.sConnectionString is simply a string property with the connection string in it. No code is run there at all.
Write To Event Log just writes whatever message is sent to the event log. Here is the code:
sSource = "Email Report Distribution"
sLog = "ERDS Error Log"
If Not EventLog.SourceExists(sSource) Then
EventLog.CreateEventSource(sSource, sLog)
End If
Dim ELog As New EventLog(sLog)
ELog.Source = sSource
Try
ELog.WriteEntry(sEvent, EventType, EvtID)
Catch ex As Exception
End Try
Your comment made me second guess this, just I just did a quick test of that by adding a couple of calls into the code that would write some event logs to check they didn't pop up something, and it didn't, so I'm pretty sure that's not it. (Actually, if it was the message would be a bit different. So it definitely couldn't be).
|
|
|
|
|
Have you considered doing a remote debug attachment? When the message box pops up, you could break the program and see where it is currently executing.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I tried that, but couldn't get it to work. However, I do have logging code throughout the application that basically updates the database to show where it's up to, so I can see that it's run that line and then the failure is either between there and the next logging point or the failure occurred doing the next logging.
And what that is showing is that it's coming up in all sorts of different places. The subroutine that was doing this was running asynchronously, so I thought maybe it didn't like that, and I tried changing things to use the openasync connection method instead of the standard open, that made no difference, so I tried changing it from being an asynchronous process to having a timer that runs every 30 seconds and runs this process synchronously on the tick. I came in this morning and the logs all showed up to date, and were continuing to update every 30 seconds, but when I logged into the server it still had a pop up there. It's like the timer ticked, ran the process, it got the pop up and stopped, but then on the next tick it ran it again and that one ran fine.
Technically that partially fixes the problem because it's not being stopped from functioning by this pop-up, probably just one of the times it ran it failed, but I really need to get rid of these pop-ups altogether. It'd driving me rather crazy. It just doesn't make sense. It's working most of the time. The process makes lots of SQL connections each time it cycles and they are working constantly, but then at some point, usually in the middle of the night, one is doing this in a way that no error handling is able to catch it.
|
|
|
|
|
Dear All,
I create one SQL Script like Insert Query and Save into Text File. I need to execute the Text File Content into Data Base using batch or whatever from VB.net Application. How to achieve this?
|
|
|
|
|
|
Hi Everyone,
Is there is an replacement/Mappings for AspTypeLibrary component. I have an VB6 legacy application migrated to VB.NET .
Iam searching for replacement to avoid registry entries and placing only in GAC.
Req = ContextUtil.GetNamedProperty("Request")
Sever = ContextUtil.GetNamedProperty("Server")
Dim Appln As ASPTypeLibrary.Application
Appln = ContextUtil.GetNamedProperty("Application")
Any help is appreciated.
Regards,
Manowj
-- modified 17-Feb-16 10:28am.
|
|
|
|
|
what the subject says
I have a server where the skript is running. Now I have the PC-Name, where i will show the inputbox. How can i do that?
|
|
|
|