how 2 write Querry in C#
-
Can any one make it syntactically correct 2 use inside c# "SELECT Word,Category,Number,Gender,Person,Degree,ObjectType,Tense,Aspect,Mood,Comp1,Comp2,Comp3,Theta1,Theta2,Theta3 FROM HindiLex,Attributes,SubCategoryFrames,ThematicFrames where HindiLex.Word = N'"+word+"'" and HindiLex.AttrNo = "Attributes.AttrNo%" and HindiLex.LexSCFNo = SubCategoryFrames.LexSCFNo and HindiLex.ThemSCFNo = ThematicFrames.ThemSCFNo";
-
Can any one make it syntactically correct 2 use inside c# "SELECT Word,Category,Number,Gender,Person,Degree,ObjectType,Tense,Aspect,Mood,Comp1,Comp2,Comp3,Theta1,Theta2,Theta3 FROM HindiLex,Attributes,SubCategoryFrames,ThematicFrames where HindiLex.Word = N'"+word+"'" and HindiLex.AttrNo = "Attributes.AttrNo%" and HindiLex.LexSCFNo = SubCategoryFrames.LexSCFNo and HindiLex.ThemSCFNo = ThematicFrames.ThemSCFNo";
You can't write a query in C#, all you can do is pass the query from C# to your database. What database are you using ? You should read some of the articles on this site, I'm sure there's one for connecting to whatever DB you use. Christian Graus - Microsoft MVP - C++
-
You can't write a query in C#, all you can do is pass the query from C# to your database. What database are you using ? You should read some of the articles on this site, I'm sure there's one for connecting to whatever DB you use. Christian Graus - Microsoft MVP - C++
Yes U R Right, I wanna pass Query fm C#. so for passing the query string syntax changes inside c#, is nt it... i want that string syntax. i am using SQL sERVER AS DB. If possible pls modify to make it syntactically correct, thank U
-
Yes U R Right, I wanna pass Query fm C#. so for passing the query string syntax changes inside c#, is nt it... i want that string syntax. i am using SQL sERVER AS DB. If possible pls modify to make it syntactically correct, thank U
cshivaprasad wrote:
so for passing the query string syntax changes inside c#, is nt it...
Nope - C# is just calling SQL Server, so the syntax has to be what SQL Server expects. If you put a @ at the front of your string, as in string s = @"this is the string"; then the only special character is to use "" for ". Otherwise, it's verbatim.
cshivaprasad wrote:
If possible pls modify to make it syntactically correct, thank U
What is the reason for htis question ? Have you connected to the DB and had an error about syntax ? Where are you putting this SQL ? Are you creatings Connection objects and so on and connecting to SQL Server ? Have you tried your SQL inside SQL Server to make sure it's good there ? Christian Graus - Microsoft MVP - C++
-
Can any one make it syntactically correct 2 use inside c# "SELECT Word,Category,Number,Gender,Person,Degree,ObjectType,Tense,Aspect,Mood,Comp1,Comp2,Comp3,Theta1,Theta2,Theta3 FROM HindiLex,Attributes,SubCategoryFrames,ThematicFrames where HindiLex.Word = N'"+word+"'" and HindiLex.AttrNo = "Attributes.AttrNo%" and HindiLex.LexSCFNo = SubCategoryFrames.LexSCFNo and HindiLex.ThemSCFNo = ThematicFrames.ThemSCFNo";
This code is susceptible to SQL Injection Attacks. You inject a variable called
word
into the query string. You should use parameters instead. See SQL Injection Attacks and Tips on How to Prevent Them[^] it will give you information on how to call SQL from C#
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871) My: Website | Blog