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
278 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 500 total points
ID: 12070103
Try using cint(cbool(migrant)).
0
 

Author Comment

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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

738 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