ADO connection string Error - sql-server-2008

Sorry for the messy outlook. This is basically a .inc file for a asp website. Currently, we have migrated from our current MySQL to MSSQL 2008. In MySQL, im able to connect to the database. But im unable to connect it under MSSQL 2008. The script works fine in MySQL. Pls help.
Information 1 : I'm using Dreamweaver.
Information 2 : I have tried strConnect = "Provider=sqloledb;Library=DBMSSOCN;Data Source=xx.xx.xx.xx;1433; Initial Catalog=mydatabasename;User Id=userID;Password=password;"
Information 3 : I can't access to the database thru the website, this is the error msg i get 500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
Information 4 :i'm lost for ideas. I searched everywhere in http://www.connectionstrings.com/sql-server-2008, http://support.microsoft.com/kb/238949, still no luck.
Information 5 : I have tried using .udl file to get the connection string. Whenever i test connection, it works perfectly shows connection passed
`<% On Error Resume Next
Set objConn = Nothing
strConnect = "Provider=sqloledb;Network Library=DBMSSOCN;Data Source=ABC-EF-SQLS01"
"Initial Catalog=mydatabasename;"
"User Id=userID;Password=password;"
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open strConnect
Function UserIP()
UserIP = Request.ServerVariables ( "HTTP_X_FORWARD_FOR" )
If UserIP = "" Then
UserIP = Request.ServerVariables ( "REMOTE_ADDR" )
End If
End Function
Function BinaryToString(Binary)
Dim cl1, cl2, cl3, pl1, pl2, pl3
Dim L
cl1 = 1
cl2 = 1
cl3 = 1
L = LenB(Binary)
Do While cl1<=L
pl3 = pl3 & Chr(AscB(MidB(Binary,cl1,1)))
cl1 = cl1 + 1
cl3 = cl3 + 1
If cl3>300 Then
pl2 = pl2 & pl3
pl3 = ""
cl3 = 1
cl2 = cl2 + 1
If cl2>200 Then
pl1 = pl1 & pl2
pl2 = ""
cl2 = 1
End If
End If
Loop
BinaryToString = nl2br(pl1 & pl2 & pl3)
End Function
Function nl2br(str)
If Not isNull(str) Then
nl2br=replace(str,VbCrLf, "<br > ")
End If
End function
Function AddZeros(str)
iLength = len(str)
iZeros = 9 - iLength
For i=1 to iZeros
str = "0" & str
Next
AddZeros = "<font color=green><b>AKC-"&str&"</b></font>"
End Function
Function DisplayDateFormat(str)
arrDate = Split(CStr(str),"/")
DisplayDateFormat = arrDate(1)&"-"&arrDate(0)&"-"&arrDate(2)
End Function
Function DBDateFormat(str)
End Function
Function doubleQuote(ByVal fixText)
doubleQuote = Replace(fixText, "'", "''")
End Function
%>

should be
Provider=sqloledb;Network Library=DBMSSOCN;Data Source=xx.xx.xx.xx,1433
note the comma for the explicit port and the Network word.
Though it may be best to just use Data Source=xxxx;
and set up network library specifics via the xxxx alias in cliconfg

Related

Collecting data from PLC every 1 sec - would like to get the data when the data changes

I am currently collecting data from my PLC with easyModbus (using Visual Basic) every 1 second with a timer and later I want to insert data to a database. My goal is to only refresh data in my program when a value changes inside of the PLC.
For example: I have 4 LEDs, 1-green 2-yellow 3-red 4-blue, and I have a timer which measures the elapsed time from when the red light comes on to when it turns of.
I want to log the time data to a database....when the error happened...when the error if fixed. But with my 1 sec refresh it is writing my data every 1 sec and I need it to only write the data when it changed...and I also don't want to ask the PLC every single second because I don't need to.
Public Sub Refresh_btn_Click() Handles Refresh_btn.Click
Dim ComError = 0 'Set comm error flag to 0
Dim Ipaddress As String
Ipaddress = "127.0.0.1"
Dim Portaddress As String
Portaddress = "502"
Dim ModbusClient As EasyModbus.ModbusClient = New EasyModbus.ModbusClient(Ipaddress, Portaddress) 'Ip address and port Text box = Ip on form
Try
ModbusClient.Connect() 'Connect to PLC
Catch ex As Exception 'What to do when error occurs
Status_lbl.BackColor = Color.Red
Status_lbl.ForeColor = Color.White
Status_lbl.Text = "Error!"
ComError = 1 'Set comm error flag to 1
End Try
If ComError = 0 Then
Status_lbl.BackColor = Color.Green
Status_lbl.ForeColor = Color.White
Status_lbl.Text = "No Error!"
'First line Andon
Dim Registers As Integer()
Registers = ModbusClient.ReadHoldingRegisters(0, 10)
'Indexing Registers starting with null
If Registers(0) = 0 Then
GreenSIGN.BackColor = Color.LightGray
YellowSIGN.BackColor = Color.LightGray
RedSIGN.BackColor = Color.LightGray
BlueSIGN.BackColor = Color.LightGray
End If
If Registers(0) = 1 Then
GreenSIGN.BackColor = Color.Green
Else
GreenSIGN.BackColor = Color.LightGray
End If
If Registers(0) = 2 Then
YellowSIGN.BackColor = Color.Yellow
Else
YellowSIGN.BackColor = Color.LightGray
End If
If Registers(0) = 3 Then
RedSIGN.BackColor = Color.Red
Else
RedSIGN.BackColor = Color.LightGray
End If
If Registers(0) = 4 Then
BlueSIGN.BackColor = Color.Blue
Else
BlueSIGN.BackColor = Color.LightGray
End If
End If
ModbusClient.Disconnect()
'Timer for downtime Static Start-Stop
Static start_time As DateTime = Now
Static stop_time As DateTime = Now
Static start_time2 As DateTime = Now
Static stop_time2 As DateTime = Now
Dim elapsed_time As TimeSpan
'Only Red Andon
'If for Red andon For Line XXX
If RedSIGN.BackColor = Color.Red Then
stop_time = Now
elapsed_time = stop_time.Subtract(start_time)
lbl_elapsed_red.Text = elapsed_time.ToString("hh\:mm\:ss")
Else
lbl_elapsed_red.Text = "Ok"
start_time = Now
End If
'Only Blue Andon
'If for Blue andon For Line XXX
If BlueSIGN.BackColor = Color.Blue Then
stop_time2 = Now
elapsed_time = stop_time2.Subtract(start_time2)
lbl_elapsed_blue.Text = elapsed_time.ToString("hh\:mm\:ss")
Else
lbl_elapsed_blue.Text = "Ok"
start_time2 = Now
End If
'Connectin MySQL
'Try
' Dim SQL As String 'SQL Command String
' Dim objCmd As New MySqlCommand 'Command
' 'Connection String to the SQL Database
' Dim Con = New MySqlConnection("server=127.0.0.1;user id=root;database=andon")
' 'SQL Statement - All values must be set for the table
' SQL = "INSERT INTO test_andon VALUES ('" & Now.ToString("yyyy/MM/dd") & "', '" & Now.ToString("HH:mm:ss") & "','" & "#dummy" & "', '" & Now.ToString("start_time2") & "', '" & "#dummy" & "', '" & "#dummy" & "')"
' Con.Open() 'Open the database connection
' objCmd = New MySqlCommand(SQL, Con) 'Set the command
' objCmd.ExecuteNonQuery() 'Execute the SQL command
' Con.Close() 'Close the database connection
'Catch ex As Exception 'What to do when an error occurs
' Status_lbl.BackColor = Color.Red
' Status_lbl.ForeColor = Color.White
' Status_lbl.Text = "Database Error Blue vége!"
'End Try
End Sub
'Timer reping
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Timer1.Interval = 100
Timer1.Enabled = True
Call Sub() Refresh_btn_Click()
End Sub
You can store the state of the red light and check if the new value is different from the old value. If it is, then write to the database and update the old value, otherwise do nothing.
For example, pretend that the incoming value related to the red light is r(t):
Imports System.Timers
Module Module1
Dim t As Integer = 0
Dim r() As Integer = {0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1}
Dim prevValue As Integer = Integer.MinValue
Sub tock(sender As Object, e As ElapsedEventArgs)
Dim val = r(t)
Console.Write(val.ToString() & " ")
If val <> prevValue Then
Console.WriteLine("Write to database.")
prevValue = val
Else
Console.WriteLine("Do nothing.")
End If
t = (t + 1) Mod r.Length
End Sub
Sub Main()
Dim tim As New Timers.Timer With {.Interval = 1000, .AutoReset = True}
AddHandler tim.Elapsed, AddressOf tock
tim.Start()
Console.WriteLine("Tocking... press enter to quit.")
Console.ReadLine()
tim.Stop()
tim.Dispose()
End Sub
End Module
Outputs:
Tocking... press enter to quit.
0 Write to database.
1 Write to database.
1 Do nothing.
1 Do nothing.
1 Do nothing.
0 Write to database.
0 Do nothing.
0 Do nothing.
0 Do nothing.
0 Do nothing.
1 Write to database.
0 Write to database.
1 Write to database.
1 Do nothing.
[Carries on until enter is pressed.]
Notice that the first value makes a write-to-database because prevValue was initialised to a value which r(t) will never have. After that, write-to-database only happens when r(t) <> r(t-1).

executescalar: Object cannot be cast from DBNull to other types

I'm having a problem when there is no data/value is fetch during running the program, I get the following error:
Object cannot be cast from DBNull to other types.
I tried validating it using if dr.hasrow() but I still get errors.
drqry = "SELECT max(num) FROM tbCVinfo WHERE cvno LIKE '%" & cvstr & "%'"
cmd2.CommandText = drqry
cmd2.Connection = con
Dim result As String = ""
cv = Convert.ToInt32(cmd2.ExecuteScalar())
'''''''''in this section I'm getting the error.
cv = cv + 1
If cv >= 0 And cv <= 9 Then
...............
Else
cn = "0001"
End If
cn = result
cvno = cn
An easy way to get around this issue is to check if the returned value is DBNull:
Dim cv As Integer
Dim queryResult = cmd2.ExecuteScalar()
If IsDBNull(queryResult) Then
' No matching records. Do something about it.
Else
cv = DirectCast(queryResult, Integer)
End If

Getting random characters when writing SMS message to .CSV (VBScript)

I am using the the program FrontlineSMS and some code written in VBScript to take incoming SMS messages and log them to a CSV file. However, random characters such as percents and numbers are ending up in the CSV file even though they are not in the SMS. Below is an example of what I mean:
I send an SMS with my phone to the modem connected to the computer reading
"07/12/2013 11:29:56 25 Happy Holidays"
The modem then receives the message and passes it on the script, which outputs it to a .CSV file. However when I open the file it reads:
"07%2F12%2F2013 | 11%3A29%3A56 | 25 | Happy | Holidays |
Where each word is in its own cell. I need help in figuring out how to get rid of the extra characters that show up (like "%2F"), my guess is that it has to do with the encryption/decryption of the characters when converting to .CSV but I don't know where to start looking to solve this.
Edit: I found out that it has to do with the ASCII coding. "%2F" is Hex for a slash "/", but I still don't know how to prevent this from happening.
Thanks!
Here is the entire script:
Option Explicit
Dim first, secnd
Dim fso, outFile
Dim strFile, strValues, strLine, strInfo
Dim stamp, num, i, identify
Const ForAppending = 8
'error handling/format
'Settings
identify = WScript.Arguments(1)
CStr(identify)
stamp = MyDate()
CStr(stamp)
strFile = "C:\SMScomm\Log\" &identify &" " &stamp & " log.csv"
'Create the file system object
Set fso = CreateObject("Scripting.FileSystemObject")
'Check whether argument were passed
If WScript.Arguments.Count <> 1 Then
WScript.Echo "No arguments were passed"
End If
strInfo = WScript.Arguments(0)
'Replace(strInfo, "%2C", ",")
'Split the argument from FSMS so it reads normally
strValues = Split(strInfo, "+")
'Open to append
Set outFile = fso.OpenTextFile(strFile, ForAppending, True)
num = UBound(strValues)
If num = 0 then
WScript.Echo "Formatting error"
End If
Do while i < num + 1
strValues(i) = strValues(i) & ","
i = i + 1
Loop
'Write to the .csv
i = 0
Do while i < num + 1
outFile.Write(strValues(i) + " ")
i = i + 1
Loop
outFile.WriteBlankLines(1)
'Close the file
outFile.Close
'Clean up
Set outFile = Nothing
Set fso = Nothing
Function MyDate()
Dim dteCurrent, dteDay, dteMonth, dteYear
dteCurrent = Date()
dteDay = Day(dteCurrent)
dteMonth = Month(dteCurrent)
dteYear = Year(dteCurrent)
MyDate = dteMonth & "-" & dteDay & "-" & dteYear
End Function
It looks like either your script or the modem is converting special characters such as "/" into their Hex format.
Can you post the script that dumps this information into CSV format?
Option Explicit
Dim first, secnd
Dim fso, outFile
Dim strFile, strValues, strLine, strInfo
Dim stamp, num, i, identify
Const ForAppending = 8
'error handling/format
'Settings
identify = WScript.Arguments(1)
CStr(identify)
stamp = MyDate()
CStr(stamp)
strFile = "C:\SMScomm\Log\" &identify &" " &stamp & " log.csv"
'Create the file system object
Set fso = CreateObject("Scripting.FileSystemObject")
'Check whether argument were passed
If WScript.Arguments.Count <> 1 Then
WScript.Echo "No arguments were passed"
End If
strInfo = WScript.Arguments(0)
'Replace(strInfo, "%2C", ",")
'Split the argument from FSMS so it reads normally
strValues = Split(strInfo, "+")
'Open to append
Set outFile = fso.OpenTextFile(strFile, ForAppending, True)
num = UBound(strValues)
If num = 0 then
WScript.Echo "Formatting error"
End If
Do while i < num + 1
strValues(i) = strValues(i) & ","
i = i + 1
Loop
'Write to the .csv
i = 0
Do while i < num + 1
Replace(strValues(i), '%2F', '/')
Replace(strValues(i), '%3A', ':')
outFile.Write(strValues(i) + " ")
i = i + 1
Loop
outFile.WriteBlankLines(1)
'Close the file
outFile.Close
'Clean up
Set outFile = Nothing
Set fso = Nothing
Function MyDate()
Dim dteCurrent, dteDay, dteMonth, dteYear
dteCurrent = Date()
dteDay = Day(dteCurrent)
dteMonth = Month(dteCurrent)
dteYear = Year(dteCurrent)
MyDate = dteMonth & "-" & dteDay & "-" & dteYear
End Function
I am sure there is a more elegant way of doing this but it should solve your problem.

VB.NET: Updating MySQL Database From (CheckedListBox-ComboBox)

I have made a form that is supposed to get the attendance details for a specific session.
The used elements are:
1- CheckedListBox
2- Combobox :CB_Students
3- Button : Update
My table is Student, which contains Code| First Name| Last Name| Day1| Day2| Day3| Day4| Day5, where the Days are of the type tinyint, referring to Presence or Absence.
I want the user to check the students' names from the CheckedListBox, so I populated the CheckedListBox with the concatenation of First Names and Last Names, each item showing the full name.
Since the CheckedListBox is indirectly created by the database records, I suppose I cannot connect it to the database directly, so I have created a hidden ComboBox with values of Code corresponding to each student shown in the CheckedListBox.
For example, my student table is as below:
Code | F_Name | L_Name
1 | F1 | L1
2 | F2 | L2
The CheckedListBox contains: F1 L1 and F2 L2, and the ComboBox contains 1 and 2.
The day number also is found during the form load and saved as the Public variable Inquiry.
Below is my code for the Update Button:
Dim j, S As Integer
sqlstr = "UPDATE Student SET Day'" & Inquiry & "'=#field1 WHERE Code='" & CB_Students.Items.Item(j) & "'"
DBCmd = New MySql.Data.MySqlClient.MySqlCommand(sqlstr, DBConn)
With DBCmd
For j = 0 To CheckedListBox1.Items.Count - 1
S = CheckedListBox1.GetItemCheckState(j)
If S = 1 Then
.Parameters.AddWithValue("#field1", 1)
ElseIf S = 0 Then
.Parameters.AddWithValue("#field1", 0)
End If
Next j
End With
DBCmd.ExecuteNonQuery()
DBCmd.Dispose()
However, during the execution, I get the error: "Parameter '#field1' has already been defined."
How should I deal with this problem?
Also, is the statement CB_Students.Items.Item(j) used correctly to give my sql string the student code in the ComboBox?
Update 1:
Inquiry is an integer. I also tried the following code:
For j = 0 To CheckedListBox1.Items.Count - 1
S = CheckedListBox1.GetItemCheckState(j)
If S = 1 Then
With DBCmd
.Parameters.AddWithValue("#field1", 1)
.ExecuteNonQuery()
.Dispose()
End With
ElseIf S = 0 Then
With DBCmd
.Parameters.AddWithValue("#field1", 0)
.ExecuteNonQuery()
.Dispose()
End With
End If
Next j
But again, as in my response to Never_Mind, I get the following error at the first DBCmd.ExecuteNonQuery() line: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''4' =1 WHERE Code='6'' at line 1".
The values seem to be correct. Day number is 4, Field1 is 1 and Code is 6. I don't see what the problem is.
Update 2:
Below is the code for populating the CheckedListBox and the ComboBox, which is in the form load. C_Code is the Class Code, another field in the student table. ClassID is a public integer variable saved in the previous form. This form appears using the .ShowDialog method.
sqlstr = "SELECT * FROM Student WHERE C_Code = '" & ClassID & "'"
DBCmd = New MySql.Data.MySqlClient.MySqlCommand(sqlstr, DBConn)
DBDR = DBCmd.ExecuteReader
While (DBDR.Read())
Std_Name = DBDR("F_Name") & " " & DBDR("L_Name")
CheckedListBox1.Items.Add(Std_Name)
CB_Students.Items.Add(DBDR("Code"))
End While
DBCmd.Dispose()
DBDR.Close()
Also, Code is integer.
Update 3:
I have changed Inquiry's datatype into String and removed the single quotes.
Anyhow, I was thinking maybe I could make different field numbers. Something like this:
Dim j, S, k As Integer
sqlstr = "UPDATE Student SET D" & Inquiry & " =#field" & k & " WHERE Code='" & CB_Students.Items.Item(j) & "' "
DBCmd = New MySql.Data.MySqlClient.MySqlCommand(sqlstr, DBConn)
For j = 0 To CheckedListBox1.Items.Count - 1
For k = 1 To CheckedListBox1.Items.Count
S = CheckedListBox1.GetItemCheckState(j)
If S = 1 Then
With DBCmd
.Parameters.AddWithValue("#field" & k, 1)
.ExecuteNonQuery()
.Dispose()
End With
ElseIf S = 0 Then
With DBCmd
.Parameters.AddWithValue("#field" & k, 0)
.ExecuteNonQuery()
.Dispose()
End With
End If
Next k
Next j
But this doesn't work. I think there should be something wrong with the way I've concatenated #field and k while adding through the command. How can I get it to work?
I would really appreciate the help!
Try this
With DBCmd
For j = 0 To CheckedListBox1.Items.Count - 1
S = CheckedListBox1.GetItemCheckState(j)
If S = 1 Then
.Parameters.AddWithValue("#field1", 1)
.ExecuteNonQuery()
ElseIf S = 0 Then
.Parameters.AddWithValue("#field1", 0)
.ExecuteNonQuery()
End If
Next
End With
Just figured the answer. Since we cannot recreate #field1, we recreate the sql string (the whole thing) by putting it in a loop.
For j = 0 To CheckedListBox1.Items.Count - 1
S = CheckedListBox1.GetItemCheckState(j)
sqlstr = "UPDATE Student SET D" & Inquiry & " =#field1 WHERE Code='" & CB_Students.Items.Item(j) & "' "
DBCmd = New MySql.Data.MySqlClient.MySqlCommand(sqlstr, DBConn)
If S = 1 Then
With DBCmd
.Parameters.AddWithValue("#field1", 1)
.ExecuteNonQuery()
.Dispose()
End With
ElseIf S = 0 Then
With DBCmd
.Parameters.AddWithValue("#field1", 0)
.ExecuteNonQuery()
.Dispose()
End With
End If
Next j
This one was quite tough! But heck, it gets easy when it's solved, eh?
First remove the single quote from the string Inquiry to concatenate the progressive of the field to the word day. BEWARE. I suppose that you have full control over the value of the Inquiry variable and check if it is a valid number before concatenating to the Day word
Second Define your parameter just once outside the loop with a dummy value, then, inside the loop set the value to the state of the current item and execute the query
Third Use a parameter also for the code value
j = 0 ' you should initialize this variable to a valid index inside the items collection of the combo'
sqlstr = "UPDATE Student SET Day" & Inquiry & "=#field1 WHERE Code=#code"
DBCmd = New MySql.Data.MySqlClient.MySqlCommand(sqlstr, DBConn)
With DBCmd
.Parameters.AddWithValue("#field1", 0)
.Parameters.AddWithValue("#code", Convert.ToInt32(CB_Students.Items(j)))
For j = 0 To CheckedListBox1.Items.Count - 1
S = if(CheckedListBox1.GetItemCheckState(j) = CheckState.Checked, 1, 0)
.Parameters("#field1").Value = S
.ExecuteNonQuery()
Next j
End With
This approach is not very efficient because an update command is executed for each day item (checked or not), but to remove this inefficiency will require a full rewrite of this code.
As for the usage of the combobox items, I think you should use the SelectedValue property, but it depends on how you have filled the combo and which value is assigned to the ValueMember property and which datatype is the code database field

Query not returning all records, need all records

I have written some code for retrieving 3 seperate columns from my database, yet for some reason it isn't loading all of the records which result from my query.
Or well, at least it doesn't seem to do so.
Also, for some reason it won't show me a messagebox which should tell me howmany records have been read after the reader is closed.
Here's my code:
Public Class frmPlayerLocations
Dim str(2), loc As String
Dim xx, yy As Integer
Dim itm As ListViewItem
Private Sub frmPlayerLocations_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ListView1.Columns.Add("ID", 60, HorizontalAlignment.Left)
ListView1.Columns.Add("Name", 115, HorizontalAlignment.Left)
ListView1.Columns.Add("Approximate Location", 115, HorizontalAlignment.Left)
Dim qry = "SELECT profile.unique_id, profile.name, survivor.worldspace FROM profile, survivor WHERE survivor.unique_id = profile.unique_id AND survivor.is_dead = '0' ORDER BY profile.name"
Dim connection As MySqlConnection
connection = New MySqlConnection()
connection.ConnectionString = "Host=" & adminPanel.IP & ";port=" & adminPanel.port & ";user=" & adminPanel.username & ";password=" & adminPanel.password & ";database=" & adminPanel.DBname & ";"
connection.Open()
Dim cmd As New MySqlCommand(qry, connection)
Dim reader As MySqlDataReader = cmd.ExecuteReader()
Dim count As Integer = 0
While reader.Read()
count += 1
str(0) = reader.GetString(0)
str(1) = reader.GetString(1)
loc = reader.GetString(2)
loc = Mid(loc, loc.IndexOf(",") + 3)
xx = CInt(Replace(Mid(loc, 1, loc.IndexOf(",")), ".", ",", 1, -1, CompareMethod.Text))
xx = (xx / 10000)
loc = Mid(loc, loc.IndexOf(",") + 2)
yy = CInt(Replace(Mid(loc, 1, loc.IndexOf(",")), ".", ",", 1, -1, CompareMethod.Text))
yy = 152 - (yy / 10000)
If xx < 100 Then
If xx < 10 Then
loc = "00" & xx.ToString & " | "
Else
loc = "0" & xx.ToString & " | "
End If
Else : loc = xx.ToString & " | "
End If
If yy < 100 Then
If yy < 10 Then
loc &= "00" & yy.ToString
Else
loc &= "0" & yy.ToString
End If
Else : loc &= yy.ToString
End If
str(2) = loc
itm = New ListViewItem(str)
ListView1.Items.Add(itm)
End While
reader.Close()
connection.Close()
MessageBox.Show(count)
End Sub
End Class
Edit: I noticed that when calling the form twice in a row, the second time I do get this error:
An unhandled exception of type 'System.ArgumentException' occurred in Microsoft.VisualBasic.dll
Additional information: Argument 'Length' must be greater or equal to zero.
And it refers to this line of code:
yy = CInt(Replace(Mid(loc, 1, loc.IndexOf(",")), ".", ",", 1, -1, CompareMethod.Text))
Last but not least, the values which are used in that line of code:
loc "7.305e-04]]" String
yy 131 Integer
PS: This may be helpful: the values which are in survivor.worldspace are in this format initially:
[168,[1291.16,5343.54,0.27]]
If the message box is not being displayed then the most likely situation is that an exception is being thrown inside the while loop which is probably silently caught somewhere else.
Unfortunately there are just too many places where an exception might occur withing that while loop so it's hard to say from just looking at that code. It could be trying to cast a DBNull to string, or an index out of bounds, etc.
My suggestion is to either step through with the debugger and identify the offending line, or put a try catch inside the while loop and put a break-point inside the catch. That should give you information about what (and where) the exception is occurring is..
Based on your update it looks like the problem is the arguments passed to the Mid() functions. Based on your data it looks like you are attempting to get a sub-string of loc using the start index of 1 and the end index of -1 which is what loc.IndexOf(",") returns in that case because there is no , (comma) in loc.
You probably want to re-factor that code a bit.. In particular it looks like you are actually trying to replace . with , but doing it after your attempt to call Mid(). That seems to be your problem!