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 3788514
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:00:41+00:00 2026-05-19T12:00:41+00:00

My code: String dbDate = DateTime.ParseExact(TextBox3.Text, dd/mm/yyyy, null).ToString(yyyy-mm-dd); SqlConnection MyConnection = new SqlConnection(Data Source=localhost;Initial

  • 0

My code:

String dbDate = DateTime.ParseExact(TextBox3.Text, "dd/mm/yyyy", null).ToString("yyyy-mm-dd");

SqlConnection MyConnection = new SqlConnection("Data Source=localhost;Initial Catalog=hcgoa;User Id=sa;Password=;");
MyConnection.Open();
String MyString = "select notice from notice_aspx where fil_no=? and orderdate=?";
SqlCommand MyCmd = new SqlCommand(MyString, MyConnection);
MyCmd.Parameters.AddWithValue("?", HiddenField4.Value);
MyCmd.Parameters.AddWithValue("?", dbDate);
using (SqlDataReader MyReader4 = MyCmd.ExecuteReader())
{
    //**
    if (MyReader4.Read())
    {

        String MyString1 = "UPDATE notice_aspx SET notice=? where fil_no=? AND orderdate=?";
        SqlCommand MyCmd1 = new SqlCommand(MyString1, MyConnection);
        MyCmd1.Parameters.AddWithValue("?", Editor1.Content.ToString());
        MyCmd1.Parameters.AddWithValue("?", HiddenField4.Value.ToString());
        MyCmd1.Parameters.AddWithValue("?", dbDate);
        MyCmd1.ExecuteNonQuery();
    }
    else
    {.........

ERROR is

Exception Details: System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near '?'.
Line 1: Incorrect syntax near '?'.

How to correct the error. Is it because i cant use ‘?’ ? Please help to sort the problem.

  • 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-05-19T12:00:42+00:00Added an answer on May 19, 2026 at 12:00 pm

    I believe that for SQL server you need to use named parameters instead of positional parameters. See the documentation for SqlCommand.Parameters for an example. So your SQL would be:

    select notice from notice_aspx where fil_no=@fil and orderdate=@orderdate
    

    (and you’d then specify those names when adding the parameters).

    Note that this has nothing to do with ASP.NET – you should be able to check this in a small console app. (You should also have using statements for your connection and command, btw.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: String inputFile = somefile.txt; FileInputStream in = new FileInputStream(inputFile);
I am trying to compile the following code: private String dataToString(){ Map data =
This code: string[] files = {test.txt, test2.txt, notes.txt, notes.doc, data.xml, test.xml, test.html, notes.txt, test.as};
My Java source code: String result = B123.replaceAll(B*,e); System.out.println(result); The output is: ee1e2e3e .
here is the code String DateOfBirth[]=strDOB.split(/); Date dateOfBirth = new Date(); dateOfBirth.setYear(Integer.parseInt(DateOfBirth[2].trim())); dateOfBirth.setMonth(Integer.parseInt(DateOfBirth[1].trim())); dateOfBirth.setDate(Integer.parseInt(DateOfBirth[0].trim()));
I am using this pattern to remove all HTML tags (Java code): String html=text
currently I have the following code: String select = qry.substring(select .length(),qry2.indexOf( from )); String[]
Can someone explain to me why my code: string messageBody = abc\n + stringFromDatabaseProcedure;
We try to convert from string to Byte[] using the following Java code: String
I have a C# application that includes the following code: string file = relativePath.txt;

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.