How do i insert true and 1 into rows during insert
I have a web page that inserts username into database, but there are other Row along with the UserName like Count and UserStatus
that i want to insert True into USERSTATUS Row and 1 into COUNT Row
See diagram below
ID USERNAME USERSTATUS COUNT
----------------------------------------
1 MIC1 TRUE 1
---------------------------------------
see insert code
protected void People(object sender, EventArgs e)
{
DataListItem item = (sender as LinkButton).NamingContainer as DataListItem;
// int bookId = Convert.ToInt32((item.FindControl("lblId") as Label).Text);
// string Name = ((item.FindControl("lblname") as Label).Text);
string usernameFollow = ((item.FindControl("lblId") as Label).Text);
// string fuserName = ((item.FindControl("lblfriendusername") as Label).Text);
// string userStatus = ((item.FindControl("lblUserStatus") as Label).Text);
// string count = ((item.FindControl("lblcount") as Label).Text);
//string status = ((item.FindControl("lblstatus") as Label).Text);
// int bookId = Convert.ToInt32((item.FindControl("lblname") as Label).Text);
using (SqlConnection con = new SqlConnection(constring))
{
if ((item.FindControl("btnLike") as LinkButton).Text.ToUpper() == "FOLLOW")
using (SqlCommand cmd = new SqlCommand("INSERT INTO FollowStatus values(@UserName,@UserStatus,@Count)", con))
{
// cmd.Parameters.AddWithValue("@UserId", Session["UserId"]);
// cmd.Parameters.AddWithValue("@BookId", bookId);
cmd.Parameters.AddWithValue("@UserName", username = this.Page.User.Identity.Name);
// cmd.Parameters.AddWithValue("@FriendUserName", usernameFollow);
cmd.Parameters.AddWithValue("@UserStatus", userStatus);
cmd.Parameters.AddWithValue("@Count", count);
// cmd.Parameters.AddWithValue("@Status", status);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
SEE TABLE BELOW
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[FollowStatus](
[Id] [int] IDENTITY(1,1) NOT NULL,
[UserName] [varchar](50) NULL,
[UserStatus] [bit] NULL,
[Count] [int] NULL,
CONSTRAINT [PK_FollowStatus] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO