john.knapp 25 Posting Whiz in Training

What exceptions do you get?
Can you provide the code for the external module?

john.knapp 25 Posting Whiz in Training

Google: vb.net 2d array tutorial OR vb.net multidimensional array tutorial

john.knapp 25 Posting Whiz in Training

Great! If you're all set, mark the question as solved please.

john.knapp 25 Posting Whiz in Training

Code Complete.
See attached project.

NOTE The application recorded is always (sic).Net SQL Client Provider, but hostnames, ip addresses, and which web method are recorded. This is not going to be a straight "drop in and go" to plug into any application, but it's a good start!

john.knapp 25 Posting Whiz in Training

This might work for you...

john.knapp 25 Posting Whiz in Training

Thanks for the feedback.
I couldn't get the CType to work, SQLBoolean wasn't a valid object type, so I tried Boolean again, and that threw an invalid cast exception. Barring any enlightening insight from the crew, I guess I'll stick with CBool(retval.Value) - which same, if my logic is working, exposes that SqlBoolean value you refer to...

What drives me batty is that I can step through with the debugger and see that retval.SqlValue has a default property of {True}

john.knapp 25 Posting Whiz in Training

OIC, sorry for the fuss

john.knapp 25 Posting Whiz in Training

I clicked through the tweets on this post and found the post had been tweeted by the C# tweeter, although it was in the VB.Net forum... Feature? DaniwebTweet

john.knapp 25 Posting Whiz in Training

Consider this:
I have a user-defined stored procedure which returns a bit value as OUTPUT.
In my calling code I want to check that value.
I define it in my code as follows:

Dim retval As New SqlParameter()
retval.ParameterName = "@return"
retval.SqlDbType = SqlDbType.Bit
retval.Direction = ParameterDirection.Output
DataCommand.Parameters.Add(retval)
DataCommand.ExecuteNonQuery()
' now check the return value
If Not (CBool(retval.Value)) Then
    Throw New ApplicationException("SQL returned FALSE. ")
End If

Which appears to get the desired results, in that my code hits the If statement and continues.
However, if I change the If statement to
If Not (CBool(retval.SqlValue)) ...
I get an exception
Conversion from type 'SqlBoolean' to type 'Boolean' is not valid
How should I be handling this? Insight, comments please.
Thanks

john.knapp 25 Posting Whiz in Training

A quick glance at the code shows you declaring your DataAdapter and DataSet as da1 ds1 respectively, but your code is using da and ds (without the "1")...

john.knapp 25 Posting Whiz in Training

Use a nested For loop.
please step through this code, I wrote it off the cuff without the IDE, and without testing, it may have undesired "features"

' this will get you started, but you'll need to figure out
' how you're going to handle the rest when you run out of
' straight number to letter substitutions
For i = 0 to 51                             ' only 26 lower and 26 upper
    For char = 65 to 122                    ' ascii values for A-Z, [ \ ] ^ _ `, a-z
        If ((char > 90) AND (char < 97))    ' skip the non-letter characters
            char = 97
        End If
        TextBox4.Text.Replace(i , Chr(char))
    Next
Next
john.knapp 25 Posting Whiz in Training

Not much detail here.. what do you have for code so far, and what is the problem you're having?

john.knapp 25 Posting Whiz in Training

Do you get an error message when trying to browse the databases? What happens if you type in the database name instead of browsing?
One way to test your db connection is to use the steps here, and use that connection string in your appication. BTW, is there a reason you're not using the SQL Native Client for your provider?

john.knapp 25 Posting Whiz in Training

Stuugie, please mark thread as solved if you're all set.
Thanks

john.knapp 25 Posting Whiz in Training

See your cross-post in the MSSQL forum for the correct query.

Generally speaking, cross-posting is bad etiquette however, and I should have had you move that post to the MSSQL forum at the beginning of the thread. Regardless, adam_k has solved your question.
Please upvote his answer and mark both threads as solved.
Thanks

john.knapp 25 Posting Whiz in Training

You're right - the OP didn't list [Transaction Details]... I had him script the db though, and that table is where the repair status is listed.

Just ran the query and got the requested results. Awesome!
Thanks for your help - I knew SUM() needed to be in there somewhere, but I was missing the CASE statement, which obviously gave me bad results.

Thanks Adam!

john.knapp 25 Posting Whiz in Training

Google: persist datagrid settings

john.knapp 25 Posting Whiz in Training

Let me be clear.
By stuck, I mean that with my current level of knowledge I am unable to solve the question.
If anyone in the MSSQL forum would like to jump in, please feel free to do so... :)
Thanks

john.knapp 25 Posting Whiz in Training

Per Microsoft kb, you can't roll it into the application installer package using the native deployment package tools; you can however, use the Setup.exe Bootstrap installer to install the .Net Framework and then kick off your app installer.

BE AWARE!!! That article appears to apply to NETFX 1.0 & 1.1 only. For NETFX 4, try this link on MSDN. There is a section in that guide for chaining your application setup directly from the NETFX setup.

john.knapp 25 Posting Whiz in Training

If these suggestions solved your issue, please mark the thread as "solved"
Thanks

john.knapp 25 Posting Whiz in Training

FWIW, I also see some text editor bugs, but cannot replicate them on demand.
Using IE Version 9.0.8112.16421 on Windows 7 Build 7601: Service Pack 1; it seems to be after a big paste operation. For me, I've only noticed issues with placing the cursor back to the end of the text - I've gotten to where I just backspace until I can "see" again.

When this does happen, it sometimes also places the last few lines from the paste operation (clipboard buffer?) in the post as well as whatver keys I'm currently pressing.

john.knapp 25 Posting Whiz in Training

Are you trying to get answers to your own questions?

Yes. I've only been a member for a month, but the answer I needed at the time was here.

What value do you get from helping people?

I still need help myself, just trying to balance the equation.

Has DaniWeb helped you forward your career?

Not yet. :)

Have DaniWeb community members evolved into quality online friends?

Not yet, I'm still "The FNG" and building rep, hopefully without stepping on any toes...

Have you ever done business with people you met on DaniWeb?

Not yet, I have picked up business from forum postings in the past however, so it does happen.

john.knapp 25 Posting Whiz in Training

As far as I can tell there are no direct equivalents to those particular preprocessor directives. There is an interesting writeup here on using the VB.Net ppd's though.

john.knapp 25 Posting Whiz in Training

Personally, I would figure out why the scheduler is failing.
Google: Programming Windows Services VB.Net for more info and tutorials

john.knapp 25 Posting Whiz in Training

I don't think so.

Let's start from the beginning.
What is this project for, is it a school project?
What are the exact requirements?

john.knapp 25 Posting Whiz in Training

[Transaction Details] is the table he wants to pull from anyway, not [Transactions].
I almost have the data, but having trouble with the outer joins/subquery select. (a bit over my head, it's been years since I did any complex queries.

Here's what I have so far:

SELECT     Description.Dgroup AS Description, COUNT(Item.IID) AS TotalCount, [Transaction Details].Ttype
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, [Transaction Details].Ttype

That query pulls the following:

Description TotalCount  CurrentStatus
Monitor 1   NULL
Object Oriented Programming 1   NULL
Printer 2   NULL
Tower   1   NULL
Printer 1   ItemTransfer
Monitor 1   Releasing
Network Switch  1   Releasing
Printer 1   Releasing
Tower   2   Releasing
USB 1   Releasing
Monitor 1   Repair
Network Switch  1   Repair
Printer 2   Repair

I'm stuck trying to get the repair count from that, while keeping the totalcount

john.knapp 25 Posting Whiz in Training

I am sure it is possible, but keeping it simple is almost always the better answer.
Why do you have the scheduler running every five minutes? Either today is my birthday or it isn't, it won't change 5 minutes from now...

john.knapp 25 Posting Whiz in Training

Almost got it, but returning count of total items under repair for each item... :(
Maybe a UNION SELECT is the way to go - but I'll have to look at it again tomorrow (UTC+5)

SELECT COUNT(Item.SID) as totalcount, Dgroup  as description,
(   SELECT --DGroup, 
      COUNT([Transaction Details].Ttype)
    FROM [Transaction Details]
      INNER JOIN [Item] ON 
        [Transaction Details].IID = Item.IID
      INNER JOIN dbo.Description ON
        [Description].DeID = [Item].DeID
     WHERE [Transaction Details].TType = 'repair'
     --GROUP BY DGroup
 ) As [Under Repair]
FROM dbo.Description INNER JOIN
    dbo.Item ON dbo.Item.DeID = dbo.Description.DeID
WHERE [Item].Status IS NULL
GROUP BY DGroup
john.knapp 25 Posting Whiz in Training

You need sub-queries, one for the totalcount and another for the repair count.
I'm working out the statements now, but I'm rusty... :)

john.knapp 25 Posting Whiz in Training

no attachment?

john.knapp 25 Posting Whiz in Training

Scheduler set to work once every day should work - what errors do you get from the scheduler?

john.knapp 25 Posting Whiz in Training

Export a script for your database please.
In VS2010, go to server explorer, right-click the server and select publish from context menu

Save, zip, and attach those scripts - make sure you script all objects

john.knapp 25 Posting Whiz in Training

Assuming your character limit is a "hard" stop, the following occurs to me:

  1. Item One: Re-use the same template instead of recreating number(x) templates
  2. Item Two: Make sure you put the bookmark back per previous link
  3. Item Three: Break the text up into "chunks" and send each chunk to a sub-procedure

Off the top code below:

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) _
                                                            Handles btnOk.Click

        'Fill the textbox first for testing
        Dim myNewLongString As String = vbNullString
        For i = 0 To 9
            myNewLongString = myNewLongString + New String(CChar(CStr(i)), 900)
        Next
        Me.txtOffense1.Text = myNewLongString

        'working variable
        Dim strToChunk As String
        'adjust chunksize as needed
        Dim chunksize As Integer = 900
        'variable to hold textbox character count
        Dim txtlength As Integer = txtOffense1.TextLength
        'how many chunks we talking about?
        Dim numberChunks As Integer = CInt(txtlength / chunksize)
        'create an array to hold the text chunks
        Dim txtchunks(0) As String

        strToChunk = Me.txtOffense1.Text

        If (strToChunk.Length > chunksize) Then
            For i = 0 To numberChunks
                If UBound(txtchunks) < i Then
                    ReDim Preserve txtchunks(i)
                End If
                If strToChunk.Length > chunksize Then
                    txtchunks(i) = Strings.Left(strToChunk, chunksize)
                    strToChunk = strToChunk.Substring(chunksize - 1)
                Else
                    txtchunks(i) = strToChunk
                End If
            Next
        Else ' less than 900 characters in original chunk
            'txtchunks(i) should still be 0 at this point
            txtchunks(0) = strToChunk
        End If

        For i = 0 To UBound(txtchunks)
            SendDataToWord(CStr(txtchunks(i)))
        Next
        ' all done with txtchunks
        Erase txtchunks

    End Sub

    Sub SendDataToWord(stringIn As String)
        ' dummy procedure
    End Sub
mrbungle commented: Great code- thanks! +2
john.knapp 25 Posting Whiz in Training

Do you not need the bookmark after the first insert operation? A quick look online shows me that unless you redefine the bookmark after inserting the text, it's lost.

Can you not just set the page layout for different first page, then let Word decide when to page break?

john.knapp 25 Posting Whiz in Training

There probably is a better way... I don't do drawing code though, so I wouldn't be much help there.

john.knapp 25 Posting Whiz in Training

You also need to add this piece of code to frmMain.vb on Line 28

Erase myCheckBoxArray

You have to erase the Array or you end up leaking memory within the application.

john.knapp 25 Posting Whiz in Training

MSDN documentation for that exception states that it is an exception thrown when an operation is performed on an already disposed object.

A lot of code executes when a form is closed, were you able to trace it to an exact line of code?

john.knapp 25 Posting Whiz in Training

The demo was not for me to do your work for you, and not for you to just plug it right into your application. You're supposed to look at it, step throught it, and learn how to code properly.

I put the checkboxes in a groupbox so that I could access the GroupBox.Controls collection property. I suggest using a GroupBox in your own project for logical grouping of controls as well as layout. If you cannot use a GroupBox, try using the Form.Controls collection instead.

For example:

For each myCheckBox in Me.Controls

john.knapp 25 Posting Whiz in Training

Assuming Visual Studio, Click View...Server Explorer
Right-Click the server, select publish to provider
Walk through the dialogs

Did you try to google "script database visual studio" yet?

john.knapp 25 Posting Whiz in Training

It looks to me like you need to start over...

  1. Item One: Only one of your arguments to the class method match a variable in the class
  2. Item Two: That's an endless If..ElseIf..Else..End If statement, use a loop
  3. Item Three: I would pass an array of checkboxes to the class method, and check from there

See demo project attached for better methodology.

john.knapp 25 Posting Whiz in Training

Thank you Dani!

john.knapp 25 Posting Whiz in Training

so much syntax, so little brainpower...
Thank you Reverend

john.knapp 25 Posting Whiz in Training

Confirmed. Both methods have 2 overloads, Save method has same overloads

 LoadFile(String)   
 LoadFile(Stream, RichTextBoxStreamType)
 LoadFile(String, RichTextBoxStreamType)
john.knapp 25 Posting Whiz in Training

Looks like I get that anytime I try to tag something without an existing tag.
I just tried tagging this article.

See attached (cropped :) screenshot

john.knapp 25 Posting Whiz in Training

drat - no substr() in VB.Net...
:)

john.knapp 25 Posting Whiz in Training

Run your application in the debugger and step through everything until you know exactly what line throws the exception.

Per MSDN library the 'System.ObjectDisposedException' is defined as:
The exception that is thrown when an operation is performed on a disposed object.

john.knapp 25 Posting Whiz in Training

Click Here

Google: vb.net subscript font

john.knapp 25 Posting Whiz in Training

It looks like you're also not even using the ds variable...

john.knapp 25 Posting Whiz in Training

Change your DataSource string - you need only the opening and closing quotes.
From:
connstring = "Data Source=.\SQLEXPRESS;AttachDbFilename=""C:\Users\Pabzz\Desktop\CSRP 10.20.12\Main\Database1.mdf"";Integrated Security=True;Connect Timeout=30;User Instance=True"

To:
connstring = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Pabzz\Desktop\CSRP 10.20.12\Main\Database1.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"

Try that and see if it helps.

john.knapp 25 Posting Whiz in Training

Why multiple reader instances? If you declare your DataReader outside of the Try block, you can re-use the same instance - you just have to close() it after each read. I don't use the OleDBDataReader so I'm not sure whether you have to also Dispose() the reader instance each time, ny gut call is "No"... to me, Dispose() implies that I am completely done with it and no longer need the object.

Clean up your code a bit and re-use the DataReader, I'll bet it works for you then.