Sorry for the early error in my post , it is Insert query not update, i need to include this CommunityStatus=1 to insert true to the column, please can you rewrite your code to insert and include CommunityStatus to insert true
ERROR
Server Error in '/' Application.
Incorrect syntax near 'MyUserName'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near 'MyUserName'.
Source Error:
Line 61: DataTable ds = new DataTable();
Line 62:
Line 63: da.Fill(ds);
Line 64:
Line 65: }
public void GetUserScraps(string username)
{
string str = ConfigurationManager.ConnectionStrings["con"].ConnectionString;
string getADPOST = "Insert INTO CommunityFollow MyUserName,FriendUserName,CommunityStatus=1 WHERE MyUserName=@MyUserName AND FriendUserName=@FriendUserName";
using (SqlConnection con = new SqlConnection(str))
{
con.Open();
using (SqlCommand cmd = new SqlCommand(getADPOST, con))
{
cmd.CommandType = CommandType.Text;
// cmd.Parameters.AddWithValue("@UserName", Request.QueryString["Id"].ToString());
cmd.Parameters.AddWithValue("@UserName", Request.QueryString["Id"].ToString());
cmd.Parameters.AddWithValue("@MyUserName", Request.QueryString["Id"].ToString());
cmd.Parameters.AddWithValue("@FriendUserName", Request.QueryString["Id"].ToString());
SqlDataAdapter da = new SqlDataAdapter(cmd);
Member
227 Points
1070 Posts
Re: How to Inserting true to row while inserting other records
Feb 08, 2016 01:47 PM|micah2012|LINK
Sorry for the early error in my post , it is Insert query not update, i need to include this CommunityStatus=1 to insert true to the column, please can you rewrite your code to insert and include CommunityStatus to insert true
ERROR