Andrews222
Technical User
Hello all,
New user here trying to figure out how to perform a (seemingly) simple task using VB.Net which I've never used before.
I'm adding a custom button and two textboxes to a form within an ERP system (Epicor) that we're installing - it's based on SQL Server.
Example: I have a table consisting of approx. 500 rows. Key field (key1) contains Zip codes and is unique, key2 also stores zip codes and another field "State" contains the state.
................Key1........Key2.......State
Row 324: "02200", "02499", "State1" // This row valid for zip codes from 02200 to 02499
Row 325: "02500", "02999", "State2" // This row valid for zip codes 02500 to 02999
The user types a zip code (let's say "02213") into TextBox01 and presses the "Lookup" button.
In MS Access w/VBA I can the result by doing this: "Select State, from UD07 where Key1 <= mZip AND Key2 >= mZip"
Here's what I've cobbled together from various internet posts so far.
The adapter (adZip) is already provided so I can connect to the appropriate database table (UD07). The table has 5 key fields - Key1 holds the lower zip range and Key2 holds the upper. Field "State" holds the state.
The variable "mZip" contains a valid zip code, but one that falls within row boundaries.
Dim dsZip As System.Data.DataSet = adZip.GetData(mZip,"","","","") ' DataSet
Dim dtTable As System.Data.DataTable = dsZip.Tables("UD07") ' DataTable
Dim ZipRow() as System.Data.Datarow
ZipRow = dsZip.Tables("UD07").Select("Key1 <= " & mZip & " AND Key2 >= " & mZip)
' Also tried - Dim ZipRow() as System.Data.Datarow = dsZip.Tables("UD07").select("Key1 = 02213")
mState = ZipRow(0)("State").ToString
So... Errors abound. I really just need to know how these objects work together, and how to assemble for this one specific task. I intend to learn the language, but can't today. Any thoughts? Just a pointer or two will be immensely helpful.
Thanks,
Andrew
New user here trying to figure out how to perform a (seemingly) simple task using VB.Net which I've never used before.
I'm adding a custom button and two textboxes to a form within an ERP system (Epicor) that we're installing - it's based on SQL Server.
Example: I have a table consisting of approx. 500 rows. Key field (key1) contains Zip codes and is unique, key2 also stores zip codes and another field "State" contains the state.
................Key1........Key2.......State
Row 324: "02200", "02499", "State1" // This row valid for zip codes from 02200 to 02499
Row 325: "02500", "02999", "State2" // This row valid for zip codes 02500 to 02999
The user types a zip code (let's say "02213") into TextBox01 and presses the "Lookup" button.
In MS Access w/VBA I can the result by doing this: "Select State, from UD07 where Key1 <= mZip AND Key2 >= mZip"
Here's what I've cobbled together from various internet posts so far.
The adapter (adZip) is already provided so I can connect to the appropriate database table (UD07). The table has 5 key fields - Key1 holds the lower zip range and Key2 holds the upper. Field "State" holds the state.
The variable "mZip" contains a valid zip code, but one that falls within row boundaries.
Dim dsZip As System.Data.DataSet = adZip.GetData(mZip,"","","","") ' DataSet
Dim dtTable As System.Data.DataTable = dsZip.Tables("UD07") ' DataTable
Dim ZipRow() as System.Data.Datarow
ZipRow = dsZip.Tables("UD07").Select("Key1 <= " & mZip & " AND Key2 >= " & mZip)
' Also tried - Dim ZipRow() as System.Data.Datarow = dsZip.Tables("UD07").select("Key1 = 02213")
mState = ZipRow(0)("State").ToString
So... Errors abound. I really just need to know how these objects work together, and how to assemble for this one specific task. I intend to learn the language, but can't today. Any thoughts? Just a pointer or two will be immensely helpful.
Thanks,
Andrew