开发者

How do I insert a checkbox into a bit type database column .Net?

So I'm trying to insert a checkbox value into a database bit type database column using .Net and MSSQL using SQL Data source. Doing it like so (codebehind):

sqlInsert.InsertParameters["company"].DefaultValue = blCompanyName.Text;
sqlInsert.InsertParameters["email"].DefaultValue = lblEmailName.Text;
sqlInsert.InsertParameters["Jan25"].DefaultValue = CheckBox1.Checked;
sqlInsert();

Then on the sql datasource I have:

<asp:SqlDataSource 
  ID="sqlInsert" 
  runat="server" 
  ConnectionString="<%$ConnectionStrings:webadsConnectionString %>"
  InsertCommand="INSERT MYTABLE (company,email,Jan25,) VALUES (@company,@email,@Jan25,)" >
<InsertParameters>
  <asp:Parameter Name="company" />            
  <asp:Parameter Name="email" />
  <as开发者_如何学Cp:Parameter Name="Jan25" Type="Boolean" />
</InsertParameters>

Any ideas how to go about achieving this? Any Help would be greatly appreciated.


Never Mind this worked out. My problem was with the database not the code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜