473,326 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

how to pass parameters in a sql query in windows form application?

i simply want to pass a parameter @str, which is coming from previous form. on the basis of this parameter, the gridview in the next table will be refined.

Expand|Select|Wrap|Line Numbers
  1.  
  2. select * from table2 where area=@str
  3.  
  4.  
now from where do i insert this parameter string 'str' in my table?
when i run the application, it simply shows all the values by taking str=null.

there would be a method for assigning the parameter value to the table.

please help!!! iam new to windows application.
Oct 19 '10 #1
3 2397
GaryTexmo
1,501 Expert 1GB
Look into how SqlParameter objects are used, that should help you out.

http://msdn.microsoft.com/en-us/libr...parameter.aspx
Oct 19 '10 #2
you can create a constructor with parameters for second form...
Expand|Select|Wrap|Line Numbers
  1.     public partial class Form2 : Form
  2.     {
  3.         string parstr;
  4.         public Form2(string str)
  5.         {
  6.             InitializeComponent();
  7.             parstr = str;
  8.         }
  9.     }
  10.  
you can use this "parameter" to make the sql command in the second form...
when you create the second form you should use something like this:
Expand|Select|Wrap|Line Numbers
  1. Form2 form2 = new Form2("John")// or the value you need...
  2.  
Oct 20 '10 #3
thank you very much GaryTexmo & Popescu Mihai, but there's an exception which is troubling now.
please check if you can help me on this.


exception -:

System.ArgumentException was unhandled
Message="No mapping exists from object type System.Data.SqlClient.SqlDataAdapter to a known managed provider native type."
Source="System.Data"
Oct 22 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: David | last post by:
So I'm a new user to Visual Studio .NET. I'm having a problem with an initial setup of a Windows Form Application for a Visual C++ Project. The Windows Form Application (.NET) template is not...
0
by: forge | last post by:
Installing Merge Modules from C# Windows Form Application (not using a setup and deployment project) Hi, Currently, we have an InstallShield project that creates a setup.exe that only...
1
by: Dean R. Henderson | last post by:
I have a Windows library that I bind into a Windows Form application and into an ASP.NET Web Application. I have a procedure in the library that executes a DTS Package. I have also used...
4
by: bob lambert | last post by:
Help I am trying to deploy to another pc a vb.net std 2002 windows form application. I am confused. I created a project - windows form I built form, compiled and debugged. I created a...
4
by: Dennis C. Drumm | last post by:
I've noticed that using Console.WriteLine statements to debug a Windows Forms Application will sometimes write output to the VS 2005 Output window and sometimes it doesn't. I know that...
3
by: Henry Seymour | last post by:
I've developed a .Net Windows Form application and used the Click-Once Deployment. In that application I would like to allow the user a click-once method of uninstalling it. I do not find an...
1
by: Dave | last post by:
Hello all, I have an application that is accessing files from a mapped drive. I have full access to the share that is mapped and from explorer can delete files as I need. My application needs to...
0
by: querry | last post by:
Hi all, I am developing a Windows form Application in VC++.NET using the Visual Studio 2005 installed on Windows Server 2003. The UI part of the project is almost complete. I am now looking forward...
1
by: Prats | last post by:
I have a windows form application developed in C++/CLR How can I verify that only one instance of the application is running on the user system at any given time. Thanks
2
by: ashkan0021 | last post by:
hi, i have a solution in C#.Net that includes 2 project and ASP.net & A Windows form application project, i want to open some pages of my asp.net project in my windows application, i'd be realy...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.