473,397 Members | 2,084 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,397 software developers and data experts.

Repost: Filling DatagraidView based on control values

Hi All

I have been searching the net on this for the last couple of hours to no
avail.

I need to fill a datagridview control based on the values entered in 2 text
boxes.
However I cant for the life of me figure out who to do this.

Here is my SQL statement:
Dim SQLString As String
SQLString = "SELECT Cutter_Num, [Size_ Across], [Size_ Back], Perf FROM
CUTTERS WHERE ([([Size_ Across] < '" & (Val(txtWidth.Text) -
Val(txtTolerance.Text)) & "'"

I don't think I am able to use the VS.net 2005 Query builder to do this. So
could anyone point me in the right direction for what I hope to achieve?

Regards

Dec 19 '05 #1
6 1346
Materialised,

It makes no sense to repost with the same message.

Probably I was not the only one who did not understand what you want to
achieve.

Maybe can yo rephrase your question?

Cor
Dec 19 '05 #2
Sorry Cor,

Let me attempt to rephrase.
Basically I have a data grid control on a form. What I wish to do is
populate this control based on the values (2 No.) that a user inputs.
For example, If the user were to enter the values 22 and 76, the data grid
would only be populated with items within that range.

I can do this using the VS.Net 2005 Query build no problem, however I am
having trouble figuring how to do it manually, i.e using a custom SQL
statement with my dataadapter to populate the datagrid.

Hope this clears some issues up with my post.

Regards
Materialised

Dec 19 '05 #3
Materialized.

Make next time your SQL string not so complicated to ask a question. What
you ask is in my opinion something as this

Dim SQLString As String
SQLString = "SELECT MyVariables from MyTable WHERE (VariableA = @One OR
VariableA = @Two")

And than manually using directly the SQLDataAdapter and not the new factored
DBprovider

\\\
dim dt as new datatable
dim conn as new SqlClient.SQLConnection("AConnectionsString")
dim da as new SqlClient.SQLDataAdapter(conn,SQLString)
Set the parameters see for that this link
http://www.vb-tips.com/default.aspx?...6-7139b8970071
da.fill(dt)
datagrid1.datasource = dt
///

All typed here so watch typos or whatever. This is very simple, you need a
Try block and as well can you set the parameters more efficient. See
partially this sample for that.

http://www.vb-tips.com/default.aspx?...a-ae802ee71c86

Using this, you can set the fill and the parameterpart in a section where
the user clicks a button to accept the values.

(The try and catch is as well not in the second sample, if you need help for
that when you have tried this, than ask again)

I hope this helps,

Cor

"Materialised" <ma**********@privacy.net> schreef in bericht
news:40*************@individual.net...
Sorry Cor,

Let me attempt to rephrase.
Basically I have a data grid control on a form. What I wish to do is
populate this control based on the values (2 No.) that a user inputs.
For example, If the user were to enter the values 22 and 76, the data grid
would only be populated with items within that range.

I can do this using the VS.Net 2005 Query build no problem, however I am
having trouble figuring how to do it manually, i.e using a custom SQL
statement with my dataadapter to populate the datagrid.

Hope this clears some issues up with my post.

Regards
Materialised

Dec 19 '05 #4
Thanks Cor,

I maybe should have stated this first, but I am using a Access database.

Will the principal you outlined also work with that?

Regards
Dec 19 '05 #5
> Thanks Cor,

I maybe should have stated this first, but I am using a Access database.

Will the principal you outlined also work with that?

Regards

Yes however have than a look at the same parameter sample on our website
with OleDb

Cor
Dec 19 '05 #6
Thank you Cor,

I figured it out with your help, and to be honest it was quite simple, so
not only have I solved my issue, I have also learnt something new today.
For anyone else having issues regarding my subject, here is the way I did
it:

Dim SQLString As String
SQLString = "SELECT Cutter_Num, [Size_ Across], [Size_ Back], Perf FROM
CUTTERS WHERE ([Size_ Across] > " & Val(txtWidth.Text) -
Val(txtTolerance.Text) & ") And ([Size_ Back] < " _
& Val(txtLength.Text) + Val(txtTolerance.Text) & ")"
Try
Dim conn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=Z:\Database\cohnan2.MDB;Persist Security Info=False"
Dim adapter As New OleDbDataAdapter(SQLString, conn)
Dim cutt As New DataSet
adapter.Fill(cutt)
DataGridView1.DataSource = cutt.Tables(0)
Catch ex As Exception
MessageBox.Show(ex.Message & vbCrLf & ex.StackTrace, "Error")
End Try

Once again, thank you very much.
Dec 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: thegame | last post by:
Filling One DataGrid Based on Selection from Another DataGrid - Both in Separate User Controls Hello, I have an interesting dilemma. I have an ASPX page with two user controls (two ASCXs). ...
5
by: Adrian Parker | last post by:
I've got the standard SqlCacheDependency working just fine , ie. I've defined (and encrypted) the connectionStrings section in the web.config, and I've also defined an an sqlCacheDependency in the...
0
by: Materialised | last post by:
Hi All I have been searching the net on this for the last couple of hours to no avail. I need to fill a datagridview control based on the values entered in 2 text boxes. However I cant for...
4
by: Dave Burns | last post by:
Hello, I am trying to specify a logical default value for a in a WCF Web Service using basicHttpBinding. I realize that the language defaults are: int - 0 string - null bool - false
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.