?
Solved

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

Posted on 2004-09-15
2
Medium Priority
?
280 Views
Last Modified: 2011-09-20
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.

Thanks
Kenny

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)

Try
                '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)
0
Comment
Question by:kwh3856
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 16

Accepted Solution

by:
RobertRFreeman earned 2000 total points
ID: 12070103
Try using cint(cbool(migrant)).
0
 

Author Comment

by:kwh3856
ID: 12092631
Robert,
Thanks for the help
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month10 days, 23 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question