•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 425,909 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,813 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser: Programming Forums
Views: 459 | Replies: 3 | Solved
![]() |
•
•
Join Date: Jun 2008
Posts: 107
Reputation:
Rep Power: 1
Solved Threads: 0
there is another problem that i am facing..i got 2 comboboxes filled with values from MS Access and they have values like 1.00,2.00,2.98,3.00,3.25 and 8.00
I want to be able to choose 2 values i.e. one value from each combo box and when I hit click I should get queries which have RAM values equal to and between the 2 chosen values from the combobox..
this query does not get executed and I get the error of datatype mismatch..i have been breaking my head to solve this but all in vain.. can u help me with this one also pls!!
I want to be able to choose 2 values i.e. one value from each combo box and when I hit click I should get queries which have RAM values equal to and between the 2 chosen values from the combobox..
this query does not get executed and I get the error of datatype mismatch..i have been breaking my head to solve this but all in vain.. can u help me with this one also pls!!
•
•
•
•
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim con As OleDbConnection = New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=C:\Documents and Settings\bashkark\Desktop\Copy of USERS.mdb")
Dim cmd1 As New OleDbCommand
cmd1 = New OleDbCommand("select * from table1 where RAM between '" CDec(ComboBox6.SelectedItem) "' and '" CDec(ComboBox7.SelectedItem) "'", con)
Dim da As OleDbDataAdapter = New OleDbDataAdapter(cmd1)
Try
Dim ds As DataSet = New DataSet()
da.Fill(ds, "table1")
DataGridView1.DataSource = ds.Tables("table1").DefaultView
Finally
con.Close()
cmd1 = Nothing
da.Dispose()
con.Dispose()
End Try
End Sub
•
•
Join Date: Apr 2008
Posts: 295
Reputation:
Rep Power: 1
Solved Threads: 41
hello,
>>> "select * from table1 where RAM between ... "
Never use *, the sign of slackers! You must always enumerate only those columns you really need for your datagrid!
There are lots of reasons for data type mismatch, so it s better you bring in the complete and exact error message.
----
tesu
>>> "select * from table1 where RAM between ... "
Never use *, the sign of slackers! You must always enumerate only those columns you really need for your datagrid!
There are lots of reasons for data type mismatch, so it s better you bring in the complete and exact error message.
----
tesu
Information is moving—you know, nightly news is one way, of course, but it's also moving through the blogosphere and through the Internets. I promise you I will listen to what has been said here, even though I wasn't here. Ann and I will carry out this equivocal message to the world. I'm the master of low expectations.
•
•
Join Date: Jun 2008
Posts: 107
Reputation:
Rep Power: 1
Solved Threads: 0
Thanks Tesuji.. I got it!! Appreicate ur help..
I have one other problem in my code..if you can take a look at it..would be great..
I have a couple of combo boxes. Any combination chosen from the combobox works. I am getting 2 errors in it.
error1: When I chose RAM as 2.98 i get 4 results
but when i chose RAM as 8 I get 2 records of 8 gb and the 4 results of 2.98 too! why is that ?
error2 : when i dont choose anything atall from any of the combo boxes, and just hit "click" in the form, the form still displays a few records in the datagridview.!
pls advise !!
I have one other problem in my code..if you can take a look at it..would be great..
I have a couple of combo boxes. Any combination chosen from the combobox works. I am getting 2 errors in it.
error1: When I chose RAM as 2.98 i get 4 results
but when i chose RAM as 8 I get 2 records of 8 gb and the 4 results of 2.98 too! why is that ?
error2 : when i dont choose anything atall from any of the combo boxes, and just hit "click" in the form, the form still displays a few records in the datagridview.!
pls advise !!
•
•
•
•
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim con As OleDbConnection = New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=Z:\CAD\Copy of USERS.mdb")
Dim cmd As New OleDbCommand
cmd = New OleDbCommand("Select * from table1 Where Mfg Like '%" & ComboBox1.SelectedItem & "%' And Make Like '%" & ComboBox2.SelectedItem & "%' And RAM Like '%" & ComboBox3.SelectedItem & "%' And GraphicsCard Like '%" & ComboBox4.SelectedItem & "%' And GraphicsVersion Like '%" & ComboBox5.SelectedItem & "%'", con)
con.Open()
Dim da As OleDbDataAdapter = New OleDbDataAdapter(cmd)
Try
Dim ds As DataSet = New DataSet()
ds.Tables.Add("table1")
da.Fill(ds, "table1")
DataGridView1.DataSource = ds.Tables("table1").DefaultView
Finally
con.Close()
cmd = Nothing
da.Dispose()
con.Dispose()
End Try
End Sub
•
•
•
•
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim con As OleDbConnection = New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=C:\Documents and Settings\bashkark\Desktop\Copy of USERS.mdb")
Dim cmd1 As New OleDbCommand
con.Open()
If (ComboBox6.SelectedItem = Nothing) Or (ComboBox7.SelectedItem = Nothing) Then
MsgBox(" Please choose 2 values")
Exit Sub
End If
cmd1 = New OleDbCommand("select * from table1 where RAM >= (" & ComboBox6.SelectedItem & " ) and RAM <= (" & ComboBox7.SelectedItem & ") ", con)
Dim da As OleDbDataAdapter = New OleDbDataAdapter(cmd1)
Try
Dim ds As DataSet = New DataSet()
da.Fill(ds, "table1")
DataGridView1.DataSource = ds.Tables("table1").DefaultView
Finally
con.Close()
cmd1 = Nothing
da.Dispose()
con.Dispose()
End Try
End Sub
![]() |
•
•
•
•
•
•
•
•
DaniWeb MS SQL Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
access advice broadband business classification code combo crime cult of the dead cow daniweb data data protection data transfer database drive dropdownlist encryption europe forensic forensics gadget google government hacking hard hardware help hitachi hp industrial espionage information internet linux mobile module net news payment services privacy protection reuse search security spot storage terabyte tutorials and more tv web wikipedia
- Previous Thread: Help with Database Query...
- Next Thread: Count Days


Linear Mode