|
| ||||||||||
| Tags: query, sql, variable |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Passing variables in SQL Query
Currently i am developing a project in the vb.net 2005, In that project I have a DataGridView of which is being populated via a table adaptor. I can populate it with a query where the value is statically assigned in the query. What I'd like is a textbox where I can type in a variable for the query and then populate the datagridview. but i am not getting how to pass the text box value to the sql query at runtime. |
|
#2
| ||||
| ||||
| Re: Passing variables in SQL Query
Firstly you need to change your query. Try something like: SELECT * FROM a table WHERE (YourField=@variable) Now, when you fill the tableadapter you will need to specify the "@variable", Me.YourTableAdapter.Fill(YourDataSet.TableName, stValueFromTextBox) Where fill is your query name, just set the value from the text box to a string, then put the string name in.
__________________ Grand Theft Auto 4 PC Video Game |
|
#3
| ||||
| ||||
| Re: Passing variables in SQL Query
Hi, you can do it by using the following code, use the following query to pass, 'get records from the customer table Dim commandString As String = _ "Select * from Customer WHERE Custid =" & TextBox1.Text.ToString & "" Hope this will help you. |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Passing variables in SQL Query" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Want to make query dependent on another query. | MACE | Software Development | 4 | 01-02-2010 04:22 PM |
| Passing variables using iframes | Sayam | Software Development | 3 | 07-08-2009 12:20 PM |
| Turn on MySQL query cache to speed up query performance | DMA2Superman | Software Development | 3 | 07-07-2009 10:26 AM |
| Use variables in a MySQL query | Chrisch | Software Development | 3 | 25-04-2009 12:11 PM |
| Passing variables from one page to another In PHP | kaartik | Software Development | 2 | 24-01-2009 08:28 PM |