There are 2 ways you can calculate the new total after removing an item from your "order".
1st you deduct the value you've removed from the total
2nd you add all the remaining values to get the new total.

I'm guessing you went for both ways at the same time.
Since you are declaring Sum for each record removed, it will be 0. Then from 0 you deduct all the prices currently found in your DGV2 (For I = 0 to DGV2.Rows.Count - 1 )
Change Sum -= DGV2.Rows(I).Cells(5).Value to Sum += DGV2.Rows(I).Cells(5).Value and you should be fine.

Shouldn't create_date be greater than or equal to now - 24 hours?

The problem is ) as x. It needs to go before the where and just after b:
I've tested this in sqlfiddle.com:

SELECT month(date),count(*)
FROM (
    SELECT CASE WHEN DATE_ADD(data1, INTERVAL num DAY) <= data2
    THEN DATE_ADD(data1, INTERVAL num DAY)
    ELSE NULL END AS date
    FROM contact_concedii
CROSS JOIN
(SELECT a.id + b.id AS num FROM (SELECT 1 AS id UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6
UNION SELECT 7 UNION SELECT 8 UNION SELECT 9 UNION SELECT 0) AS a
CROSS JOIN (SELECT 0 AS id UNION SELECT 10 UNION SELECT 20 UNION SELECT 30 UNION SELECT 40 UNION SELECT 50
UNION SELECT 60 UNION SELECT 70 UNION SELECT 80 UNION SELECT 90 ) AS b ) AS x
    WHERE CASE WHEN DATE_ADD(data1, INTERVAL num DAY) <= data2
    THEN DATE_ADD(data1, INTERVAL num DAY)
    ELSE NULL END IS NOT NULL
) AS c
GROUP BY month(date)

The results are:

| MONTH(DATE) | COUNT(*) |
--------------------------
|           1 |        4 |
|           2 |       21 |

So I'm guessing you are really after something like:

| ID | MONTH(DATE) | COUNT(*) |
-------------------------------
|  1 |           1 |        1 |
|  2 |           1 |        1 |
|  3 |           1 |        2 |
|  3 |           2 |       21 |

For this you'll need this:

SELECT id, month(date),count(*)
FROM (
    SELECT id, CASE WHEN DATE_ADD(data1, INTERVAL num DAY) <= data2
    THEN DATE_ADD(data1, INTERVAL num DAY)
    ELSE NULL END AS date
    FROM contact_concedii ...

What I don't like is "shared" and "intervals". Even in small scale shared workbooks can cause user frustration and problems. Running a job at intervals reading a shared workbook, that users might be still editing - but haven't saved or have saved half-way sounds like bad idea.

May I propose an Excel macro using ADODB to insert records directly in SQL ?
I've used this in past to read & write to SQL and you simply give a template to the user to fill in and when done he/she has to press a button and the magic happens.

The code required should be :

Public Sub create_request()
Dim conn As New ADODB.Connection
Dim comm As New ADODB.Command
Dim rs As New ADODB.Recordset

conn.ConnectionString = "Your connection string here"
conn.Open

comm.ActiveConnection = conn
comm.CommandText = "insert into table (column1, column2, column3) values ('" & 
Sheets("Sheet1").Range("A2").Value & "','" & Sheets("Sheet1").Range("B2").Value & "','" & Sheets("Sheet1").Range("C2").Value & "')" 

comm.Execute
End If

If you have multiple records to insert, you can either loop through records or union them in a select.

I prefer it this way, because users know instantly if their insert succeeded and the template can be nice, with vlookups, data validation, calculations and whatever Excel supports. You also can save with data from several worksheets and can validate before the insert.

I've checked the above and it did contain errors, so below is the corrected script (but I haven't tested this one either):

select month(date),count(*) 
from (
    select DATEADD(dd, num , @start_date ) as date from 
(select a.id + b.id as num from 
(select 1 as id union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9 union select 0) a cross join 
(select 0 as id union select 10 union select 20 union select 30 union select 40 union select 50 union select 60 union select 70 union select 80 union select 90 ) b ) c
) d
where date < @end_date
group by month(date)

What you do with it is:

select month(date),count(*) 
from (
    select case when DATEADD(dd, num , data1 ) <= data2 
    then DATEADD(dd, num , data1 )
    else null end as date
    from tablename 
cross join 
(select a.id + b.id as num from (select 1 as id union select 2 union select 3 union select 4 union select 5 union select 6 
union select 7 union select 8 union select 9 union select 0) a 
cross join (select 0 as id union select 10 union select 20 union select 30 union select 40 union select 50 
union select 60 union select 70 union select 80 union select 90 ) b 
    where case when DATEADD(dd, num , data1 ) <= data2 
    then DATEADD(dd, num , data1 )
    else null end is not ...

On the top of my head (and with MS SQL in mind) it is possible, but a) it won't be nice and b) I don't know how much use it'll be to anybody.

If you create a set of days from beginning until end of period, you can count(*) group by month :

select month(date),count(*) 
from (
    select DATEADD(dd, num , @start_date ) as date 
(select a.id + b.id as num from 
(select 1 as id union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9 union select 0) a full join 
(select 0 as id union select 10 union select 20 union select 30 union select 40 union select 50 union select 60 union select 70 union select 80 union select 90 ) b )
) 
where date < @end_date

Please note a couple things on the above query:
1) I'm using a series of numbers from 0 to 99 to calculate the dates in the period. So this query is limited to 99 days between start date and end date. If you need more days you need to add a "table" like a and b with values 0 to 900.
2) I prefer calculating the dates over using a calendar table, as this method is maintenance free and will work for any given period - if SQL supports the date.
3) I haven't tested it, so it might contain errors.

If your issue is solved, please mark this thread as solved.

The dim keywords() = {..} will declare an array.
The for each key as string in keywords will step through the array's ellements.
This way you can use the same code and save yourself a huge pile of if...else if.... else...
If you can't go with Word, perhaps it's time to get back to why do you use a word file? Can't it be a simple text file?

I would suggest to get yourself a big enough NAS (Network Attached Storage) and copy everything there.
I saves you the trouble of swapping disks and the risk of falling one of them or windows messing up your filesystem with repeated ejections and insertions.
They may have a slower speed, but NAS come with all options of RAID - which gives it the ability to repopulate a bad disk once replaced, without any loss of data - always depending on the type of RAID and the depth of your wallet.

I think that calling Word.Application requires word to be installed - and obviously licensed.
Anyway:

Sub ShallReadRoutine() 
dim keywords() = {"shall read","test1","test2") 

for each key as string in keywords 
LEDDisplaySearch = Procedure.IndexOf(key)

if LEDDisplaySearch <> -1
    TopDisplay = procedure.substring(LEDDisplaySearch + 10, 7)
    BottomDisplay = Procedure.substring(LEDDisplaySearch + 18,7)

select  case key
    case "shall read" 
        UUTBox.RichTextBox4.text = TopDisplay 
        UUTBox.RichTextBox3.text = BottomDisplay
    case else
        cobj(key & "upper").text = TopDisplay
        cobj(key & "lower").text = BottomDisplay 
end if 

next

This might give you an idea.
If you are looking for the next "shall read" part then you should use the overloaded IndexOf and specify as startIndex the last index or the last index + how many chars you need to.
Try to use meaningfull names in your objects. RichTextBox4 will only get you lost inside your code and will make troubleshooting or future releases harder.
In the case else part I've used test1upper, test1lower, test2upper and test2lower as textboxes (or richtextboxes) and used the same code for both sets of objects. If this isn't your case, you can repeat the case "shall read" part with different objects or whatever.

Please note that the above code hasn't been tested and may contain typos or other errors.

Good luck.

I never needed to hot swap disks, but you could try to go to computer management/Disk management and right click the disk and select offline. I don't know if windows will find your second disk and make it online or if you will have to make it online yourself.
If it works, it appears that you can create a script with diskpart.

Be warned: I haven't tried this and I wouldn't do it with 2 disks full with data I would miss if they were gone. BACK UP FIRST.

Are you building this in Word VBA or are you calling Word from your application or you got your string in your app and need to handle it?
Please any code you've got, for us to see how you've got this far.

To help you find out the problem change the error msgbox to display the exception you've caught, instead of the generic "Sorry Cannot open Server Connection".
Also, since you are using Trusted Connection, I assume windows user from the client machines have been granted login to SQL and access to this db. (I'd ask if the password has expired or has been changed in the current windows session, but you've mentioned xp sp2 and windows 7, so I'm assuming it's at least 2 pcs and hopefully 2 accounts).

You should join all 3 tables and only select from the 2 you need to:

select directives.comments, para_comments_sect.comments 
from directives inner join para on directives.para_id = para.id 
inner join para_comments_sect.para_id = para.id 
where para.id = 15 -- replace the where clause with whatever you need to

select directives.comments, para_comments_sect.comments
from directives inner join para on directives.para_id = para.id
inner join para_comments_sect.para_id = para.id
where para.id = 15 -- replace the where clause with whatever you need to

Try this:

SELECT A.AccountID,
        A.LastName,
        B.Paid
 FROM A, (SELECT AccountID, SUM(InvCurrency) as 'Paid' FROM B
 WHERE B.BillingPeriodStart Between '2012-01-01 00:00:00.000' AND '2012-12-31 23:59:59.000' AND 
  StatusID = 1 AND
 (ServiceCode=13 OR ServiceCode=14) AND
 (ServiceCode=15 OR ServiceCode=16) AND
 (ServiceCode=17 OR ServiceCode=18) AND
 (ServiceCode=19 OR ServiceCode=20) AND
 (ServiceCode=21 OR ServiceCode=26)
Group By AccountID ) B 
 on A.AccountID = B.AccountID 
 order by LastName

You are assuming that the field exceeding the field size is filebytes. It doesn't have to be, so check the length of filetype,filename, etc.

You can also specify parameters on CR and filter your results with that, directly in the report.

Oracle isn't my strong suite, but:

  1. No.
    2 & 3: Find your connectionstring here: http://www.connectionstrings.com/oracle

Case won't work in Access.
Try a statement like
select * from table order by closing Is Not Null, Closing

Try something like:

    Dim last_value As String = ""
    Dim last_color As Color = Color.LightBlue

    If DataGridView1.Rows.Count > 0 Then
        For Each row In DataGridView1.Rows

            If DataGridView1.Item("houseno", row.index).Value <> last_value Then
                If last_color = Color.LightBlue Then
                    DataGridView1.Rows(row.index).DefaultCellStyle.BackColor = Color.LightGray
                Else
                    DataGridView1.Rows(row.index).DefaultCellStyle.BackColor = Color.LightBlue
                End If
            Else
                DataGridView1.Rows(row.index).DefaultCellStyle.BackColor = last_color
            End If

            If DataGridView1.Rows(row.index).IsNewRow = False Then
                last_value = DataGridView1.Item("houseno", row.index).Value.ToString
                last_color = DataGridView1.Rows(row.index).DefaultCellStyle.BackColor
            End If

        Next

    End If

Depending on what you want to store your options might change.
Since you look new to this I'd suggest you look into My.Settings for storing a few values.
Read here for a short tutorial: http://www.daniweb.com/software-development/vbnet/code/296812/storing-and-retrieving-application-user-settings

This might be silly, but if it's VB.NET shouldn't you use "&" instead of "+" for concatenation?

This should return the siblings:

"select b.studentname,b.class from 
vw_admissionform a inner join vw_admissionform b 
on a.familycode = b.familycode 
and a.regno = '" & txt1.text & "' 
and a.studentname <> b.studentname"

you can include in the select all the fields from your query - if you want them in the same record - like this :

"select a.familycode,a.regno,a.studentname,a.class, b.studentname,b.class from 
vw_admissionform a inner join vw_admissionform b 
on a.familycode = b.familycode 
and a.regno = '" & txt1.text & "' 
and a.studentname <> b.studentname"

Please note that I haven't tested the above queries and they may contain typos.

satti commented: WORKS PERFECTLY :) GOD BLESS YOU +0

Did you get an error?
What do you mean no luck?
Did ps_producy_shop contain any of the id_category_default you were trying to insert?

I believe you are thinking sequential here, and dbs are powerfull only when they process bulk data.
What you should do is join the tables in an update statement with id_product as key and a where that will filter only the records where ps_product_shop <> id_category_default.
It should look like :

update table_name2 
set ps_product_shop = id_category_default
from table_name1 inner join table_name2 on table_name1.id_product = table_name2.id_product 
where ps_product_shop <> id_category_default

This is in MS SQL syntax, so you might need to change it a bit for MySql.
After you've updated the records where ps_product_shop doesn't match the id_category_default, then you should insert the missing records.
Again I would use join:

insert into table_name2 (field1, field2, field3) 
select field1, field2, field3 from table_name1 left join table_name2 
on table_name1.id_product = table_name2.id_product 
and ps_product_shop = id_category_default
where table_name2.id_product is null 

The above will join the 2 tables and then filter out the records that have in both tables same id_product and ps_product_shope = id_category_default.

It doens't have to complicated with joins or subqueries:

SELECT     Description.Dgroup AS Description, COUNT(Item.IID) AS TotalCount, 
sum(case when [Transaction Details].Ttype = 'Repair' then 1 else 0 end) as 'Under Repair'
FROM         [Transaction Details] RIGHT OUTER JOIN
                      Item ON [Transaction Details].IID = Item.IID LEFT OUTER JOIN
                      Description ON Item.DeID = Description.DeID
WHERE     (Item.Status IS NULL)
GROUP BY Description.Dgroup

But I don't see transaction details as a table in the original post and the [Description].[Dgroup] that OP is trying to select doesn't appear in table specs.

You can declare a var to hold your query in the declarations part of your form (before the first sub) and a second one to hold your query criteria. This will give your vars scope for all events in this form and allow you to use them in 2 or more different subs.

When coding the textchanged events instead of declaring a string for your query, use the ones that have scope the entire form. Check if the query_criteria one has a value assigned and if it does concatenate your new criteria at the end (make sure you concatenate a space in there as well). If it doesn't have a value assign it one.

execute your query by concatenating the 2 string vars (the query and the query criteria) for each of the 2 subs.

The only way for you to replace only the "encoded" characters is to go character by character. Your best bet is to use a dictionary and step through each character.
There is no difference between what you are trying to do and the post I've mentioned above .
The easiest way for you to do it is to use GeekByChoiCe's code and change the dictionary to fit your "language". If you don't want to do it in a second textbox, then use a variable for your conversion and at the end change your textbox.text to what the variable holds.