Hi..I am new bie in ASP.NET, i face a problem to convert the string value into boolean, below is my back end code:
Protected Sub btnInsert_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnInsert.Click
Dim strConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\smart_touch\smart_touch_project\survey\App_Data\DB\Survey.mdb;Persist Security Info=True" 'connection string
Dim objConnection As New OleDbConnection(strConnectionString)
objConnection.Open() ' open connection
Try
Dim insertStr As String = "INSERT INTO tblSurvey(Potential,HRDS," & _
")VALUES(?,?)"
Dim uCmd As New OleDbCommand(insertStr, objConnection)
wankit
0 Points
2 Posts
How to convert string into boolean value?
Dec 16, 2008 01:11 PM|LINK
Hi..I am new bie in ASP.NET, i face a problem to convert the string value into boolean, below is my back end code:
Protected Sub btnInsert_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnInsert.Click
Dim strConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\smart_touch\smart_touch_project\survey\App_Data\DB\Survey.mdb;Persist Security Info=True" 'connection string
Dim objConnection As New OleDbConnection(strConnectionString)
objConnection.Open() ' open connection
Try
Dim insertStr As String = "INSERT INTO tblSurvey(Potential,HRDS," & _
")VALUES(?,?)"
Dim uCmd As New OleDbCommand(insertStr, objConnection)
uCmd.Parameters.Add("Potential", OleDbType.VarChar).Value = dd_potential.SelectedValue.ToString
uCmd.Parameters.Add("HRDS", OleDbType.Boolean).Value = radiobtn_hrds.SelectedValue.ToString
uCmd.ExecuteNonQuery()
Catch ex As Exception
Response.Write(" no ok")
Response.End()
Finally
objConnection.Close()
End Try
End Sub
When i run in visual studio 2008, it appear error "Failed to convert parameter value from a String to a Boolean."
I think the problem is come out from statement: uCmd.Parameters.Add("HRDS", OleDbType.Boolean).Value = radiobtn_hrds.SelectedValue.ToString
Hope could hear reply soon....
Thank you for viewing and helping[:)]
vb.net code behind asp.net 2.0
allanhorwitz
Contributor
2517 Points
623 Posts
Re: How to convert string into boolean value?
Dec 16, 2008 01:23 PM|LINK
DkUltra
Contributor
2813 Points
546 Posts
Re: How to convert string into boolean value?
Dec 16, 2008 06:52 PM|LINK
Why not use radiobtn_hrds.checked, which is a boolean value
assuming radiobtn_hrds is a radio button.
Hope this helps
DK