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

  • Home
  • SEARCH
  • 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 708037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:20:43+00:00 2026-05-14T04:20:43+00:00

I am using in C# MYsql .I have query that works if I run

  • 0

I am using in C# MYsql .I have query that works if I run on MySql Workbench ,but in C# it does not return any value also does not give ant error too.There is only one different using on Mysql I use before table name databaseName.tableName , but in C# I think it doesn`t necessary.
This is part of query which does not return anything.

EDIT :SOLVED

"(select Lesson_Name from schedule  where Group_NO = (select Group_NO from sinif inner join student ON sinif.Group_ID=student.Group_ID where Student_Name=(?Student))"+
           " And Day_Name =(select Day_Name from day inner join date ON day.Day_ID=date.DayName where Date=(?Date))" +
           "And Lesson_Time= (select Lesson_Time from clock where Lesson_Time <= (?Time)order by Lesson_Time DESC limit 0, 1) " +
           " And Week_NO = (select Week_NO from week inner join date ON week.Week_ID=date.Week_ID where Date=(?Date)))

And Here all codes which executes when user click button.

 private void check_B_Click(object sender, EventArgs e)
    {

        connection.Open();

       for (int i = 0; i < existingStudents.Count; i++)
        {
            MySqlCommand cmd1 = new MySqlCommand("select Student_Name,Student_Surname,Student_MacAddress from student  ", connection);
            MySqlCommand cmd2 = new MySqlCommand("insert into check_list (Student,Mac_Address,Date,Time,Lesson_Name)"+
           "values((?Student),(?MacAddress),(?Date),(?Time),"+
           "(select Lesson_Name from schedule  where Group_NO = (select Group_NO from sinif inner join student ON sinif.Group_ID=student.Group_ID where Student_Name=(?Student))"+
           " And Day_Name =(select Day_Name from day inner join date ON day.Day_ID=date.DayName where Date=(?Date))" +
           "And Lesson_Time= (select Lesson_Time from clock where Lesson_Time <= (?Time)order by Lesson_Time DESC limit 0, 1) " +
           " And Week_NO = (select Week_NO from week inner join date ON week.Week_ID=date.Week_ID where Date=(?Date))))", connection);

            MySqlParameter param1 = new MySqlParameter();
            param1.ParameterName = "?Student";
            reader = cmd1.ExecuteReader();
            if (reader.HasRows)
                while (reader.Read())
                {
                    if (reader["Student_MacAddress"].ToString() == existingStudentsMac[i].ToString())
                        param1.Value = reader["Student_Name" ]+" "+reader["Student_Surname"];
                }

            reader.Close();

            MySqlParameter param2 = new MySqlParameter();
            param2.ParameterName = "?MacAddress";
            param2.Value = existingStudentsMac[i];

            MySqlParameter param3 = new MySqlParameter();
            param3.ParameterName = "?Date";
            param3.Value = DateTime.Today.Date;

            MySqlParameter param4 = new MySqlParameter();
            param4.ParameterName = "?Time";
            param4.Value = DateTime.Now.ToString("HH:mm");


            cmd2.Parameters.Add(param1);
            cmd2.Parameters.Add(param2);
            cmd2.Parameters.Add(param3); 
            cmd2.Parameters.Add(param4);

           cmd2.ExecuteNonQuery();

        }


        connection.Close();
        MessageBox.Show("Sucsess :)");

    }
  • 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-14T04:20:44+00:00Added an answer on May 14, 2026 at 4:20 am

    With a long experiments )) I found my mistakes.MySqlParameter param1 has value for Student_Name and I also added Student_Surname but in my table there was only Student_Name and because of that they dont match. Also param4.ParameterName = "?Time"; was return system time but with a different time format .I changed it to param4.Value=DateTime.Now.ToString("hh:mm");
    Alson I recognized that instead of using Lesson_Time <= (?Time) using Lesson_Time <= ('?Time')solved problem .I think in my table I defined time of lessons as a string and (‘?Time’) returns string.

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

Sidebar

Related Questions

Please note that this question is not about the mysql query per se, but
I have tried fetching MySQL query results using mysql_fetch_row() and mysql_result() and numeric values
I have been using the MySql Query Browser and [opinion]it has to be the
I have a dataset in MySQL where using limit is already an expensive query,
I am using MySQL and I have a table with an index that is
(Using MySQL and PHP) I have a search form that will allow my users
I have a MySQL query that I'd like help optimizing. Its rather simple in
If i run every block of this script in mysql-query-browser, it works. If i
I have a bulk query with subquery. My query works fine when I run
So I have an SQL dump file that needs to be loaded using mysql_query().

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.