Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7753659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:06:29+00:00 2026-06-01T12:06:29+00:00

I have to use the @(I don’t know it’s name). I can use it

  • 0

I have to use the “@”(I don’t know it’s name). I can use it in update delete or insert statements but I cannot use it in there it gives URL MUST BE DECLARED

       //SQL string to count the amount of rows within the OSDE_Users table
        string sql = "SELECT * FROM RSSFeeds where URL = @URL";

        SqlCommand cmd = new SqlCommand(sql, Connect());

        cmd.Parameters.Add("@URL", SqlDbType.VarChar, 500).Value = url;
        closeConnection();
        SqlDataAdapter adapt = new SqlDataAdapter(sql, Connect());
        DataSet ds = new DataSet();
        adapt.Fill(ds);

        // result of query filled into datasource
        adapt.Dispose();

        closeConnection();

        return ds;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:06:30+00:00Added an answer on June 1, 2026 at 12:06 pm

    I can only suppose that this line is not correct:

    cmd.Parameters.Add("@URL", SqlDbType.Int).Value = url;
    

    Probably URL is not an Int but a NVarChar or other character type
    If this is the case then change your line in this way
    (255 is the supposed length of your field URL)

    cmd.Parameters.Add("@URL", SqlDbType.NVarChar, 255).Value = url;
    

    And, by the way, ‘@’ is called “Parameter Prefix”

    EDIT: Seeing the last edit from the OP I update my answer to show what I think is the correct way to go.

       //SQL string to count the amount of rows within the OSDE_Users table 
        string sql = "SELECT * FROM RSSFeeds where URL = @URL"; 
    DataSet ds = new DataSet(); 
        using(SqlConnection cnn = Connect())
        using(SqlCommand cmd = new SqlCommand(sql, cnn)) 
        {
            cmd.Parameters.Add("@URL", SqlDbType.VarChar, 500).Value = url; 
            using(SqlDataAdapter adapt = new SqlDataAdapter(cmd))
            {
    
                adapt.Fill(ds); 
            }
        }
        return ds; 
    

    What I have changed:

    • Encapsulated every disposable object inside an using statement that
      is guaranteed to close/dispose objects
    • Called Connect() just one time and captured the SqlConnection returned to
      reuse without creating another one
    • Created the SqlDataAdapter using the SqlCommand created before (so
      the @URL parameter reaches the Sql)

    The OP used a closeConnection() and we don’t see the internal of this method, but I think that using is enough to close and dispose the connection.

    EDIT: The line that creates SqlDataAdapter should be

    using(SqlDataAdapter adapt = new SqlDataAdapter(cmd))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't have any experience with SVG but I was hoping to use this
I don't have admin rights to my pc, but would like to use Mercurial
I don't know which title I should use for this question. I have a
I don't have a use case for this but I was recently asked this
I have an ADO.NET disconnected DataSet. I don't need or can use an ADO.NET
I don't understand why livequery doesn't bind the event, but I have to use
I don't want to use fixtures at all. There is a flag you can
Often we have to use some of the methods which don't return anything useful.
I don't use Eclipse as an IDE, and have no interest in doing so.
I don't use tab panel just tab bar, and have to prevent changing tab

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.