I need to pass query something like
Select * from EmpTable where EmpName LIKE '%ARP%' in application configuration file. ?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Omar MaherRank #1,337 · 1.3K reputationPosted May 23, 2017, 11:19 PM EDT
static void Main() { string cstr = "server=(local)\\SQLEXPRESS;database=MyDatabase;Integrated Security=SSPI;"; using ( SqlConnection conn = new SqlConnection( cstr ) ) { conn.Open(); string selstr = "select FirstName from Employee where lastname = @name"; SqlCommand cmd = new SqlCommand( selstr, conn ); SqlParameter name = cmd.Parameters.Add( "@name", SqlDbType.NVarChar, 15 ); name.Value = "Tang"; SqlDataReader rdr = cmd.ExecuteReader(); if ( rdr.Read() ) { Console.WriteLine(rdr.GetString( 0 ) ); } else { Console.WriteLine("not available yet" ); } } }Manas MohapatraRank #182 · 13.2K reputationPosted May 23, 2017, 10:11 PM EDT
Omar MaherRank #1,337 · 1.3K reputationPosted May 23, 2017, 10:26 PM EDT
Nepethya RanaRank #4,361 · 348 reputationPosted May 23, 2017, 10:26 PM EDT
Nepethya RanaRank #4,361 · 348 reputationPosted May 23, 2017, 10:28 PM EDT