[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
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
?
281 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

649 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