M
Marcin Wiszowaty
im using asp and vs03 vb but i understand some c#
im trying to make a checkbox's checked (true|false) value update a sqlserver
2000 table.
the db type for that field is bit. and i would like to keep it that way so
the datagrid shows the check box instead of a text value
im getting this error
Error is ->Syntax error converting the varchar value 'F' to a column of data
type bit.
code ****************
Dim one As Integer ' this is only trying to pass an int wiould have
worked
' i also tried to pass a boolean
string and chars didnt work
' i tried casting the update
querystring fields but i dont know weather i did that right please review it
below
one = 0
Dim dt As DataTable
dt = Me.DsUsers2.Tables("usertable")
Dim dr1 As DataRow()
dr1 = dt.Select("UserId = '" & Me.lblUserId.Text & "'")
dr1(0)("UserId") = dr1(0)("UserId") ' only reason im setting them
to themselves is because when i dont set them it gives the same error and
just to show the complete table
dr1(0)("fname") = dr1(0)("fname")
dr1(0)("lname") = dr1(0)("lname")
dr1(0)("departament") = Int32.Parse(ddlDepts.SelectedItem.Value)
dr1(0)("isdepartamenthead") = chbDepartamenthead.checked
dr1(0)("iscoordinator") = one
dr1(0)("extension") = dr1(0)("extension")
dr1(0)("email") = dr1(0)("email")
Me.SqlDataAdapter1.Update(dr1)
/code **********************
update query string generated by vs -> UPDATE usertable SET UserId =
@UserId, Fname = @Fname, Lname = @Lname, Departament = @Departament,
isdepartamenthead = @isdepartamenthead, iscoordinator = @iscoordinator,
extension = @extension, email = @email WHERE (UserId = @Original_UserId);
SELECT UserId, Fname, Lname, Departament, isdepartamenthead, iscoordinator,
extension, email FROM usertable WHERE (UserId = @UserId)
with my cast -> UPDATE usertable SET UserId = @UserId, Fname = @Fname, Lname
= @Lname, Departament = @Departament, isdepartamenthead = cast(
@isdepartamenthead as bit) , iscoordinator = cast( @iscoordinator as bit),
extension = @extension, email = @email WHERE (UserId = @Original_UserId);
SELECT UserId, Fname, Lname, Departament, isdepartamenthead, iscoordinator,
extension, email FROM usertable WHERE (UserId = @UserId)
this cast doesnt work when tried the gives same error
Thank you for your help.
im trying to make a checkbox's checked (true|false) value update a sqlserver
2000 table.
the db type for that field is bit. and i would like to keep it that way so
the datagrid shows the check box instead of a text value
im getting this error
Error is ->Syntax error converting the varchar value 'F' to a column of data
type bit.
code ****************
Dim one As Integer ' this is only trying to pass an int wiould have
worked
' i also tried to pass a boolean
string and chars didnt work
' i tried casting the update
querystring fields but i dont know weather i did that right please review it
below
one = 0
Dim dt As DataTable
dt = Me.DsUsers2.Tables("usertable")
Dim dr1 As DataRow()
dr1 = dt.Select("UserId = '" & Me.lblUserId.Text & "'")
dr1(0)("UserId") = dr1(0)("UserId") ' only reason im setting them
to themselves is because when i dont set them it gives the same error and
just to show the complete table
dr1(0)("fname") = dr1(0)("fname")
dr1(0)("lname") = dr1(0)("lname")
dr1(0)("departament") = Int32.Parse(ddlDepts.SelectedItem.Value)
dr1(0)("isdepartamenthead") = chbDepartamenthead.checked
dr1(0)("iscoordinator") = one
dr1(0)("extension") = dr1(0)("extension")
dr1(0)("email") = dr1(0)("email")
Me.SqlDataAdapter1.Update(dr1)
/code **********************
update query string generated by vs -> UPDATE usertable SET UserId =
@UserId, Fname = @Fname, Lname = @Lname, Departament = @Departament,
isdepartamenthead = @isdepartamenthead, iscoordinator = @iscoordinator,
extension = @extension, email = @email WHERE (UserId = @Original_UserId);
SELECT UserId, Fname, Lname, Departament, isdepartamenthead, iscoordinator,
extension, email FROM usertable WHERE (UserId = @UserId)
with my cast -> UPDATE usertable SET UserId = @UserId, Fname = @Fname, Lname
= @Lname, Departament = @Departament, isdepartamenthead = cast(
@isdepartamenthead as bit) , iscoordinator = cast( @iscoordinator as bit),
extension = @extension, email = @email WHERE (UserId = @Original_UserId);
SELECT UserId, Fname, Lname, Departament, isdepartamenthead, iscoordinator,
extension, email FROM usertable WHERE (UserId = @UserId)
this cast doesnt work when tried the gives same error
Thank you for your help.