Syntax error converting the varchar value 'True' to a column of data type bit.......Attempting to use the Cbool command

I am attempting to read a value that is either a 1 or 0.  I want to save it in a SQL database as a Boolean value.  Any ideas on what I am doing wrong.


Here is my code

Syntax error converting the varchar value 'True' to a column of data type bit.

Here is the code

Database structure field is set to bit as the type

Dim migrant As String

migrant = Mid(strLine, 102, 1)

                'Insert Records into StudentInfo
                Dim objConnection7 As SqlConnection = New SqlConnection("server=(local);database=FBISD-TAKS;user id=sa;password=pa55word")
                Dim objCommand7 As SqlCommand = New SqlCommand
                objCommand7.Connection = objConnection7
                objCommand7.CommandText = "Insert Into studentInfo " & "(admDate,grade,studentId, esc, lname, fname, mi, sex, dob, ethnicity, ecoDis, title1, migrant, lep) " & _
                            "VALUES(@iadmDate,@grade,@studentId, @esc, @lname, @fname, @mi, @sex, @dob, @ethnicity, @ecoDis, @title1, @migrant, @lep)"
                objCommand7.Parameters.Add("@iadmDate", SqlDbType.DateTime, 10).Value = madmDate
                objCommand7.Parameters.Add("@grade", SqlDbType.Int, 4).Value = grade
                objCommand7.Parameters.Add("@studentid", SqlDbType.Int, 4).Value = Val(studentId)
                objCommand7.Parameters.Add("@esc", SqlDbType.Int, 4).Value = Val(esc)
                objCommand7.Parameters.Add("@lname", SqlDbType.VarChar, 14).Value = lname.Trim
                objCommand7.Parameters.Add("@fname", SqlDbType.VarChar, 14).Value = fname.Trim
                objCommand7.Parameters.Add("@mi", SqlDbType.VarChar, 2).Value = mi.Trim
                objCommand7.Parameters.Add("@sex", SqlDbType.VarChar, 1).Value = sex
                objCommand7.Parameters.Add("@dob", SqlDbType.DateTime, 10).Value = mdob
                objCommand7.Parameters.Add("@ethnicity", SqlDbType.Int, 4).Value = Val(ethnicity)
                objCommand7.Parameters.Add("@ecoDis", SqlDbType.Int, 4).Value = Val(ecoDis)
                objCommand7.Parameters.Add("@title1", SqlDbType.Int, 4).Value = Val(title1)
                objCommand7.Parameters.Add("@migrant", SqlDbType.Bit, 1).Value = CBool(migrant)
Who is Participating?
RobertRFreemanConnect With a Mentor Commented:
Try using cint(cbool(migrant)).
kwh3856Author Commented:
Thanks for the help
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.