SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Convert SQL QUERY TO C# QUERY
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

immad
Posting Yak Master

Pakistan
220 Posts

Posted - 04/29/2013 :  01:09:52  Show Profile  Reply with Quote
HELLO I MAKE A QUERY AND I WANT TO RUN IN C# DATA ADAPTER

my query is like this

"select * from inventory where (isnull('" + DropDownList2.Text +"','')='' OR RAM = '" + DropDownList2.Text + "' and (ISNULL ('"+DropDownList1.Text + "','')='' OR PCNAME='" + DropDownList1.Text + "'"))
but when i write in C# coding it gives me this error.

Incorrect syntax near 'PENTIUM 4'. <----- THIS IS PCNAME

and this is real query that i write in sql server

select * from inventory WHERE
(ISNULL(@RAM,'')='' OR RAM = @RAM)
AND (ISNULL(@PC,'')='' OR PCNAME = @PC)
AND (ISNULL(@IP,'')='' OR IPADDRESS = @IP)
AND (ISNULL(@OS,'')='' OR OS = @OS)
AND (ISNULL(@CPU,'')='' OR CPU = @CPU)
AND (ISNULL(@MB,'')='' OR MB = @MB)
AND (ISNULL(@HDD3,'')='' OR HDD3 = @HDD3)


please help me i am new in sql


immad uddin ahmed

Edited by - immad on 04/29/2013 01:14:17

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 04/29/2013 :  01:25:12  Show Profile  Reply with Quote
i see two braces in the end. are they part of sql? if yes it should be

"select * from inventory where (isnull('" + DropDownList2.Text +"','')='' OR RAM = '" + DropDownList2.Text + "' and (ISNULL ('"+DropDownList1.Text + "','')='' OR PCNAME='" + DropDownList1.Text + "'))"



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

immad
Posting Yak Master

Pakistan
220 Posts

Posted - 04/29/2013 :  01:57:04  Show Profile  Reply with Quote
THANKS ITS WORKING



immad uddin ahmed
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 04/29/2013 :  02:21:18  Show Profile  Reply with Quote
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 04/29/2013 :  02:21:19  Show Profile  Reply with Quote
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.16 seconds. Powered By: Snitz Forums 2000