-1

I'm working on an appointment project, and I'm having trouble comparing the column name in SQL with a variable name in C#.

I have these variables, each of which is associated with a radio button on my form:

int time1;
int time2;
int time3;
int time4;
int time5;  // etc...

Additionally I have columns with the same name in a SQL table, and I want to compare each variable name with the column names, and if they are equal then update the value.

Rufus L
  • 36,127
  • 5
  • 30
  • 43
  • 1
    "*i want to check if one of them checked update this column in sql which equal the same name*" try and make this statement a little better so we can understand what you want. Its a little fractured – TheGeneral Nov 22 '19 at 23:51
  • hope now better thank you – Hassan Sniper Hamo Nov 23 '19 at 00:00
  • 1
    There are better ways to bind form data to a database, although that is a broad topic that has many tutorials online. The names of the variables should not be bound to column names in SQL. – Rufus L Nov 23 '19 at 00:27
  • I re-worded your question for clarity, but please it and make sure I understood you correctly. – Rufus L Nov 23 '19 at 00:29

1 Answers1

0

It's not clear what you want to do, but I think this can help you: get name of a variable or parameter

Also, you can get the column name using INFORMATION_SCHEMA: https://learn.microsoft.com/en-us/sql/relational-databases/system-information-schema-views/columns-transact-sql?view=sql-server-ver15

rlm96
  • 193
  • 1
  • 15