473,395 Members | 1,404 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,395 software developers and data experts.

VB / SQL Question

I'm using MS VB Express Ed. 2005.

I have an sql database. This database has one table, and there is a
column called salesman.

I want to AUTOMATICALLY enter the salesman name for every new record
created.

The salesman name will be taken from a list of six possible salesman in
strict order. i.e. salesman one for the first record, salesman two for
the second, etc... until record seven arises, which will be given
salesman one, ad infinitum.

The form will need to have an option to 'skip' a salesman if he is not
available, in which case the salesman ascribed to the record should
then become the next salesman from the list. However for the next
record added, it should revert back to the salesman that was
unavailable.

the whole point is i need to generate a system which allocated incoming
leads to the salesman in a fair impartial manner.

someone suggested the following sql query to me, but it makes no sense
to me - do you think this is what i'd need? and if so can you please
explain it. and how i would enter this in vb express as i have only
used ms access in the past.

===
You need to record the datetime that each salesman do their thing. Use
this
query and pick the one at the top of the list.

SELECT Table26.name AS [Up Next], Last(Table26.leadtime) AS [Last Time]

FROM Table26
GROUP BY Table26.name
ORDER BY Last(Table26.leadtime);
I do not know how you expect to skip the salesman that aren't available
unless you are going to record their not being present as a sales
activity.
=====================

Thankyou very much.

Gary.

Oct 21 '05 #1
1 1162
Gary, if I understand you correctly, you basically need to have

Position 1 - Salesman 1 Name
Position 2 - Salemsan 2 Name
Position 3 - Salesman 3 Name
Position 4 - Salesman 4 Name
Position 5 - Salesman 5 Name
Position 6 - Salesman 6 Name
Position 1 - Salesman 1 Name 'repeat at this point.

Now, let's say that this could be 100 salesman, just replace the code below
with a call to your database table with their names (if you have index
numbers assigned, use them, oterhwise you can use the autoincrement approach
I used). Afterward, you'll have them all inserted correctly and you can
just do a straight update to the databse (note that you'll need to change
the counter to static to ensure that different instances of the form all use
the same number. Youc an created a class for this or if you're using
VB.NET, you can use that Module thingy which is essentially a class with all
static properties. Again though, how you want to make this determination on
behavior is up to you, In this case it would reset itself for each instance
of the form or each time it loaded - which would unfairly favor the guys at
the front - you could fix that by using a Random or, if I understood you
right, a static would meet your needs to handle it sequentially. HOWEVER,
you might need to keept he counter in the db if you need it to be consistent
against each instance of the app. For the same reasons that an instance
variable would unfairly favor guys at the beginning, even a static would
favor them unless you got the variable from some central place b/c let's
say that you had 5 users simultaneously. So user 1 does 2 of these, then
user 2 starts up, and does 2, then 3 does the same. Salesman 1 and 2 would
be selected three times each and the otehr guys would never get picked... if
you store the value in a db or web service (and keep it static in the web
service) then this would be alleviated - Needless to say, there's some
thought that needs to go into this, I mention it only to bring it to your
attention.

This code should do it for you though assuming you tweak the scope fo the
variables to match your business rules:

Int32 Counter = -1;
DataTable salesman = new DataTable("SalesmanLookup");
DataTable realTable = new DataTable("RealTable");

private void button4_Click(object sender, System.EventArgs e)
{
DataColumn dc = new DataColumn("ID", typeof(Int32));
dc.AutoIncrement = true;
dc.AutoIncrementSeed = 0;
DataColumn dc2 = new DataColumn("SalesmanName", typeof(String));
salesman.Columns.Add(dc);
salesman.Columns.Add(dc2);
DataRow dro = salesman.NewRow();
dro[1] = "Salesman1Name"; //Add each Salesman's real name, I just used fake
ones
salesman.Rows.Add(dro);
dro = salesman.NewRow();
dro[1] = "Salesman2Name";
salesman.Rows.Add(dro);
dro = salesman.NewRow();
dro[1] = "Salesman3Name";
salesman.Rows.Add(dro);
dro = salesman.NewRow();
dro[1] = "Salesman4Name";
salesman.Rows.Add(dro);
dro = salesman.NewRow();
dro[1] = "Salesman5Name";
salesman.Rows.Add(dro);
dro = salesman.NewRow();
dro[1] = "Salesman6Name";
salesman.Rows.Add(dro);
salesman.AcceptChanges(); //Since this is just a lookup, we don't need to
ave the values/
//However, you could extract these from a Database or other source
DataColumn dcReal = new DataColumn("SalesmanName", typeof(String));
realTable.Columns.Add(dcReal);
}
private void button5_Click(object sender, System.EventArgs e)
{
if(Counter == 5)
{
Counter = 0;
}
else
{
Counter++;
}
DataRow dro = realTable.NewRow();
dro[0] = salesman.Rows[Counter][1].ToString();
Debug.WriteLine(String.Format("Counter: {0} Salesman: {1}",
Counter.ToString(), salesman.Rows[Counter][1].ToString()));
}

<ga********@myway.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
I'm using MS VB Express Ed. 2005.

I have an sql database. This database has one table, and there is a
column called salesman.

I want to AUTOMATICALLY enter the salesman name for every new record
created.

The salesman name will be taken from a list of six possible salesman in
strict order. i.e. salesman one for the first record, salesman two for
the second, etc... until record seven arises, which will be given
salesman one, ad infinitum.

The form will need to have an option to 'skip' a salesman if he is not
available, in which case the salesman ascribed to the record should
then become the next salesman from the list. However for the next
record added, it should revert back to the salesman that was
unavailable.

the whole point is i need to generate a system which allocated incoming
leads to the salesman in a fair impartial manner.

someone suggested the following sql query to me, but it makes no sense
to me - do you think this is what i'd need? and if so can you please
explain it. and how i would enter this in vb express as i have only
used ms access in the past.

===
You need to record the datetime that each salesman do their thing. Use
this
query and pick the one at the top of the list.

SELECT Table26.name AS [Up Next], Last(Table26.leadtime) AS [Last Time]

FROM Table26
GROUP BY Table26.name
ORDER BY Last(Table26.leadtime);
I do not know how you expect to skip the salesman that aren't available
unless you are going to record their not being present as a sales
activity.
=====================

Thankyou very much.

Gary.

Oct 21 '05 #2

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

Similar topics

1
by: Mohammed Mazid | last post by:
Can anyone please help me on how to move to the next and previous question? Here is a snippet of my code: Private Sub cmdNext_Click() End Sub Private Sub cmdPrevious_Click() showrecord
3
by: Stevey | last post by:
I have the following XML file... <?xml version="1.0"?> <animals> <animal> <name>Tiger</name> <questions> <question index="0">true</question> <question index="1">true</question> </questions>
7
by: nospam | last post by:
Ok, 3rd or is it the 4th time I have asked this question on Partial Types, so, since it seems to me that Partial Types is still in the design or development stages at Microsoft, I am going to ask...
3
by: Ekqvist Marko | last post by:
Hi, I have one Access database table including questions and answers. Now I need to give answer id automatically to questionID column. But I don't know how it is best (fastest) to do? table...
10
by: glenn | last post by:
I am use to programming in php and the way session and post vars are past from fields on one page through to the post page automatically where I can get to their values easily to write to a...
10
by: Rider | last post by:
Hi, simple(?) question about asp.net configuration.. I've installed ASP.NET 2.0 QuickStart Sample successfully. But, When I'm first start application the follow message shown. ========= Server...
53
by: Jeff | last post by:
In the function below, can size ever be 0 (zero)? char *clc_strdup(const char * CLC_RESTRICT s) { size_t size; char *p; clc_assert_not_null(clc_strdup, s); size = strlen(s) + 1;
56
by: spibou | last post by:
In the statement "a *= expression" is expression assumed to be parenthesized ? For example if I write "a *= b+c" is this the same as "a = a * (b+c)" or "a = a * b+c" ?
2
by: Allan Ebdrup | last post by:
Hi, I'm trying to render a Matrix question in my ASP.Net 2.0 page, A matrix question is a question where you have several options that can all be rated according to several possible ratings (from...
3
by: Zhang Weiwu | last post by:
Hello! I wrote this: ..required-question p:after { content: "*"; } Corresponding HTML: <div class="required-question"><p>Question Text</p><input /></div> <div...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.