forum

Home / DeveloperSection / Forums / Updating query with comparison between string and varchar(max)

Updating query with comparison between string and varchar(max)

Kate Smith225319-Jun-2013
Hi Developers,

I have an updating query like this:

 public void Update_Download(string _url){
            Data.Connect();
            using (Data.connexion)
            {
                string queryString = "update Fichier set Last_download=@last , Downloads_count= Downloads_count + 1  where Url = @url ";
                SqlCommand command = new SqlCommand(queryString, Data.connexion);
                command.Parameters.AddWithValue("@last", DateTime.Now);
                command.Parameters.AddWithValue("@url", _url);
                try
                {
                  SqlDataReader reader = command.ExecuteReader();
                 }
                catch { }
                }
         }
    }
}

the string connection :

public static SqlConnection connexion;
        public static bool  Connect()
        {
                System.Data.SqlClient.SqlConnectionStringBuilder builder = new System.Data.SqlClient.SqlConnectionStringBuilder();
                builder["Initial Catalog"] = "Upload";
                builder["Data Source"] = "bd";
                builder["integrated Security"] = true;
                string connexionString = builder.ConnectionString;
                connexion = new SqlConnection(connexionString);
                try { connexion.Open(); return true; }
                catch { return false; }
        }
        public static  void Disconnect()
        {
            if (connexion != null) connexion.Close();
            connexion = null;
        }

the query is executing without exception but nothing is changed in table. the type of the attribute Url is varchar(Max) and the DBMS is Sql Server.

So what is the problem? how can i correct my query?


Updated on 19-Jun-2013

Can you answer this question?


Answer

1 Answers

Liked By