Alexandrumbm
Programmer
Hello to you all,
I have a problem reading from the database some values.
If one of the value is empty i get this error message:
Conversion from type 'DBNull' to type 'String' is not valid.
How can i pass thru this problem ?
Please give me a suggestion and how can i optimize this code better!
---------------------------------------------
Dim denumire_furnizor, tip_unitate, statut_juridic As String
conn.Open()
Dim sql_1 = "SELECT denumire FROM unitatea_economica"
cmd = New OleDb.OleDbCommand(sql_1, conn)
denumire_furnizor = CStr(cmd.ExecuteScalar)
Dim sql_1_1 = "SELECT tip_unitate FROM unitatea_economica"
cmd = New OleDb.OleDbCommand(sql_1_1, conn)
tip_unitate = CStr(cmd.ExecuteScalar)
Dim sql_1_2 = "SELECT statut_juridic FROM unitatea_economica"
cmd = New OleDb.OleDbCommand(sql_1_2, conn)
statut_juridic = CStr(cmd.ExecuteScalar)
Me.lbl_furnizor.Text = tip_unitate & " " & denumire_furnizor & " " & statut_juridic
If conn.State <> ConnectionState.Closed Then
conn.Close()
End If
-----------------------------------------
Thanks alot and please to escuse me for my bad english!
I have a problem reading from the database some values.
If one of the value is empty i get this error message:
Conversion from type 'DBNull' to type 'String' is not valid.
How can i pass thru this problem ?
Please give me a suggestion and how can i optimize this code better!
---------------------------------------------
Dim denumire_furnizor, tip_unitate, statut_juridic As String
conn.Open()
Dim sql_1 = "SELECT denumire FROM unitatea_economica"
cmd = New OleDb.OleDbCommand(sql_1, conn)
denumire_furnizor = CStr(cmd.ExecuteScalar)
Dim sql_1_1 = "SELECT tip_unitate FROM unitatea_economica"
cmd = New OleDb.OleDbCommand(sql_1_1, conn)
tip_unitate = CStr(cmd.ExecuteScalar)
Dim sql_1_2 = "SELECT statut_juridic FROM unitatea_economica"
cmd = New OleDb.OleDbCommand(sql_1_2, conn)
statut_juridic = CStr(cmd.ExecuteScalar)
Me.lbl_furnizor.Text = tip_unitate & " " & denumire_furnizor & " " & statut_juridic
If conn.State <> ConnectionState.Closed Then
conn.Close()
End If
-----------------------------------------
Thanks alot and please to escuse me for my bad english!