Hi all, need your help again..
I have a trouble when running my application which is "Input string was not in a correct format". I imported my data from xls,
and i use
From Xls file the value of m1std = 0.00002691, i have set the format into number with 10 decimal places, but i dont know how the data reader recognize the variable as string, i put value and show it to messagebox, the value become 2.691E-05. I think the .net thinks there is a character "E", and it recognize the variable become string. How to solve this?
Thanks in advance
I have a trouble when running my application which is "Input string was not in a correct format". I imported my data from xls,
VB.NET:
Dim cnstr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & txtfName.Text & ";" & _
"Extended Properties =""Excel 8.0;HDR=YES;IMEX=1;"""
VB.NET:
Dim m1std As Decimal = 0
VB.NET:
While oledbdr.Read()
If Not oledbdr.IsDBNull(25) Then
m1std = Decimal.Parse(oledbdr(25))
Else
m1std = 0.0
End If
end while
VB.NET:
insertintosqlOPEX( mat1, m1std, mat1vol, mat1rpsat, mat1rp)
VB.NET:
Public Sub insertintosqlOPEX( ByVal mat1 As String, ByVal m1std As Decimal, ByVal mat1vol As Decimal, ByVal mat1rpsat As Decimal, ByVal mat1rp As Decimal)
strSQL = "INSERT INTO " & tblname & "( Mat1, M1std, MAT1Vol,MAT1RpSat,MAT1Rp) VALUES ( @mat1, @m1std, @mat1vol, @mat1rpsat, @mat1rp )"
Dim sqlcmd2 As New SqlCommand
sqlcmd2.Connection = oconnection
sqlcmd2.Parameters.Add("@Mat1", SqlDbType.VarChar, 255).Value = mat1
Dim pm1std As New SqlParameter()
With pm1std
.Value = m1std
.ParameterName = "@M1std"
.SqlDbType = SqlDbType.Decimal
.Precision = 15
.Scale = 10
End With
sqlcmd2.Parameters.Add(pm1std)
'sqlcmd2.Parameters.Add("@M1std", SqlDbType.Decimal, 9).Value = m1std
Dim pmat1vol As New SqlParameter()
With pmat1vol
.Value = mat1vol
.ParameterName = "@mat1vol"
.SqlDbType = SqlDbType.Decimal
.Precision = 15
.Scale = 5
End With
sqlcmd2.Parameters.Add(pmat1vol)
'sqlcmd2.Parameters.Add("@mat1vol", SqlDbType.Float, 8).Value = mat1vol
Dim pmat1rpsat As New SqlParameter()
With pmat1rpsat
.Value = mat1rpsat
.ParameterName = "@mat1rpsat"
.SqlDbType = SqlDbType.Decimal
.Precision = 15
.Scale = 5
End With
sqlcmd2.Parameters.Add(pmat1rpsat)
'sqlcmd2.Parameters.Add("@mat1rpsat", SqlDbType.Float, 8).Value = mat1rpsat
Dim pmat1rp As New SqlParameter()
With pmat1rp
.Value = mat1rp
.ParameterName = "@mat1rp"
.SqlDbType = SqlDbType.Decimal
.Precision = 15
.Scale = 5
End With
sqlcmd2.Parameters.Add(pmat1rp)
sqlcmd2.CommandText = strSQL
sqlcmd2.CommandType = CommandType.Text
sqlcmd2.ExecuteNonQuery()
Thanks in advance