in asp.net application I bulk insert records using OPENXML, into table
"myTable".
which has the following field:

column name : myCol
dataType : bit

.... ... ..

myCommand.CommandText = "select myCol from myTable "
adapter.SelectCommand = myCommand
adapter.TableMappings.Add("Table", "myTable")
adapter.Fill(dS)

Dim tbl As DataTable = ds.Tables("myTable")

for i=0 to 1
Dim NewRow As DataRow = tbl.NewRow()
NewRow("myCol") = 1 'get converted automatically by the compiler to:
true/false
tbl.Rows.Add(NewRow) ' which generate the error.
next

Dim sb As StringBuilder = New StringBuilder(1000)
Dim sw As System.IO.StringWriter = New System.IO.StringWriter(sb)
Dim col As DataColumn
For Each col In tbl.Columns
col.ColumnMapping = System.Data.MappingType.Attribute
Next

ds.WriteXml(sw, System.Data.XmlWriteMode.WriteSchema)

myCommand.Connection = cn
myCommand.CommandType = CommandType.StoredProcedure
myCommand.CommandText = "myStoredProcedure"

myCommand.Parameters.Add(New SqlParameter("@xmldata",
System.Data.SqlDbType.NText))
myCommand.Parameters(0).Value = sb.ToString()

Dim a As String
cn.Open()
com.ExecuteNonQuery()
cn.Close()


'error : Syntax error converting the nvarchar value 'true' to a column of
data type bit

explicit conversion of true/false to int return always "True"/"False" wording

thanks for help

Re: convert true to 1 by Cor

Cor
Fri May 27 06:29:00 CDT 2005

Zino,

Can you set Option Strict On in your program.
Than you will be pointed on things which can give errors at run time.

I hope this helps,

Cor