Oxiegen 88 Basically an Occasional Poster Featured Poster

No matter what the database backend is and no matter what type of database connection you use, you can still throw SQL commands at it and it will return the data.

Dim value As Integer
Dim con As New OleDbConnection(<connectionstring>)
Dim com As OleDbCommand

Private Sub ReadValue()
    com = New OleDbCommand("SELECT MAX(<column>) FROM <table>")

    con.Open()
    Dim reader As OleDbDataReader = com.ExecuteReader()

    If reader.HasRows Then
        reader.Read()
        value = reader(0)
    End If
    reader.Close() '<-- Note! Do NOT use con.Close() here.
End Sub

Private Sub AddAndInsert()
    value += 1

    com = New OleDbCommand("INSERT INTO <table> (<column>) VALUES (" & value & ")")

    con.Open()
    com.ExecuteNonQuery()
    con.Close()
End Sub
Oxiegen 88 Basically an Occasional Poster Featured Poster

This is a fully working code.
I noticed one thing that caused problems. The column name Size is a reserved word, so you need to put brackets [] around it.

Imports System
Imports System.IO
Imports System.Text
Imports System.Data.OleDb

Public Class frmBirthdayCake
    Private sql As String = "SELECT CakeID,Cake_Name,Cake_Description,Weight,Price,Image,ShelfLife,[Size],NoOfServings FROM Birthday_Cake"
    Private dt As New DataTable
    Private con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\CakeAlbum.accdb")
    Private adapter As New OleDbDataAdapter(sql, con)
    Dim index As Integer

    Private Sub frmBirthdayCake_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        con.Open()
        adapter.Fill(dt)

        DataGridView1.DataSource = dt
        DirectCast(DataGridView1.Columns("Image"), DataGridViewImageColumn).ImageLayout = DataGridViewImageCellLayout.Stretch

        For i As Integer = 0 To dt.Rows.Count - 1
            Dim row As DataGridViewRow = DataGridView1.Rows(i)
            row.Height = 60
        Next

        DataGridView1.Columns("Image").Width = 150
        con.Close()
    End Sub

    Private Sub btnNext_Click(sender As System.Object, e As System.EventArgs) Handles btnNext.Click
        If TextBox1.Text = "" Then
            index = 0
        ElseIf index = dt.Rows.Count - 1 Then
            Exit Sub
        Else
            index += 1
        End If

        TextBox1.Text = dt.Rows(index)(0)
        TextBox2.Text = dt.Rows(index)(1)
        ReadImage()
    End Sub

    Private Sub btnPrevious_Click(sender As System.Object, e As System.EventArgs) Handles btnPrevious.Click
        If TextBox1.Text = "" OrElse index = 0 Then
            index = 0
        ElseIf index = dt.Rows.Count - 1 OrElse index <> 0 Then
            index -= 1
        End If

        TextBox1.Text = dt.Rows(index)(0)
        TextBox2.Text = dt.Rows(index)(1)
        ReadImage()
    End Sub

    Private Sub ReadImage()
        Try
            Dim imageBytes() As Byte = CType(dt.Rows(index)(2), Byte())
            Using ms As New MemoryStream(imageBytes)
                PictureBox1.Image = Image.FromStream(ms)
                PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
            End Using
        Catch ex As Exception

        End Try
    End Sub

    Private Sub DataGridView1_CellMouseClick(sender As Object, e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles …
Ashveen96 commented: thanks a lot this works!!! +0
Oxiegen 88 Basically an Occasional Poster Featured Poster

Simple SQL query: SELECT MAX(<column name>) FROM <table>
The MAX() function works with both numbers and strings.
http://msdn.microsoft.com/en-us/library/ms187751.aspx

Oxiegen 88 Basically an Occasional Poster Featured Poster

As suggested by the title of this thread, you already know how to connect a database to the report.
Based on that I would like to point out that a dataset/datatable is an "internal" database of sorts.
So, if you dump those numbers into a datatable from the datagridview and connect that to the report you can go from there.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Well. You can't pass information back to the main form if you close it.
You have already hidden it. Isn't that enough?

Suggestion. If the second form is nothing but a data retriever, sorter and parser, open it as a modal form instead and throw a progressbar on it or something and keep the main form open in the background.
When the job is done, close the second form from within itself.

Oxiegen 88 Basically an Occasional Poster Featured Poster

It sounds like those "texts" that you scrape from the screen are log messages of some type.
Wouldn't it be easier to create a program that connects to the server and retrieve those log files, instead of scraping the screen or in this case the content of another program.

If you absolutely need to go the scrape way, there are only two options.
1) Capture a screenshot and try to ocr it.
2) Create a hook to that software you're using and "read" the content of the objects being returned. (http://www.codeproject.com/Articles/33459/Spying-Window-Messages-from-the-Inside)

Oxiegen 88 Basically an Occasional Poster Featured Poster

You can remove the part with the newValue variable.
It does almost the exaxt same thing as the three lines above it.

Oxiegen 88 Basically an Occasional Poster Featured Poster

You need two string variables.

You can perform a line read using the appropriate filereader object and append the line into a temp string variable through a simple loop.
And for each line you can in addition perform some string manipulation.
So for each line the only contains "" or " ", you can skip to the next line so that empty lines do not get read into the permanent string variable.

Additionally, during the manipulation phase you can do a simple string replacement.
:'++' becomes vbNewLine (or vbCrLf) and so on.
By using two variables you can append the last know good string to the "real" string.

The String object contains a whole bunch of useful tools to do exactly what you're asking for.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Never mind. I figured it out.
I forgot that I have a second router installed at my neighbour connected to my lan through it's wan port, and that it too had dhcp activated. :|

Oxiegen 88 Basically an Occasional Poster Featured Poster

Hey, I've got kind of a weird problem.

I've set up a local network at home using a Netgear WNDR3700v3 router, which works flawlessly. And I've set it up so that connected computers get all the IP-information from the router (DHCP), including using the router as the dns.
But every night, the dns on the connected computers are being replaced with the ip 172.16.0.1 (I'm using 192.168.0.x on my lan).

On rare occations I don't notice anything different, but most of the time my browsers fail to resolve hosts.

At this point I've begun thinking maybe a worm or some other kind of virus. But I've never heard of a virus that do this.
Any ideas of what might be the cause?

Oxiegen 88 Basically an Occasional Poster Featured Poster

The best option would be to load both databases into their own dataset. That way, when you do the compare, nothing gets pushed to the sql server and cost time.

Also, using the ID as the comparer is a horrible idea.
You should use a selection of fields for comparison.

Insert Into sql.table1 From access.table1 Where Not sql.field1 = access.field1 And Not sql.field2 = access.field2 (and so on)

When you use datasets, and more specifically datatables, you can use the built-in method .ImportRow().

Dim srcDt As DataTable = srcDs.Tables(0) <-- Your Access Db
Dim trgDt As DataTable = trgDs.Tables(0) <-- Your SQL Db

For i As Integer = 0 To srcDt.Rows.Count - 1
    trgDt.ImportRow(srcDt.Rows(i))
Next

After that you follow up with an iteration to check for, and delete, duplicates.
And finally, submit the target dataset to SQL Db.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Have a look at Gembox Spreadsheet.
You can do pretty much anything with it concerning excel/xml.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Just for kicks.
Try putting that code in a separate method and call it from the Load method.
But also include a class boolean variable.

Private bIsLoading As Boolean = True

Private Sub frmcrc_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    If bIsLoading Then
        LoadValues()
    End If
    bIsLoading = False
End Sub

Private Sub LoadValues()
    'Your code
End Sub

This is just to make sure that the code is not being executed twice.
I've had the happen to me once or twice when I had some code in the Form_Load event.

Oxiegen 88 Basically an Occasional Poster Featured Poster

DIM is the keyword used in Visual Basic to declare a variable.

VB: Dim varname As Object
C#: object varname;

ddanbe commented: ok +15
Oxiegen 88 Basically an Occasional Poster Featured Poster

Take a look at SpiceWorks.

It's an inventory system that can collect information about IT hardware remotely.
Though it also has a "client" agent that can be installed on your users computers for deep and detailed information, basic info can be retrieved without it using only system queries and WMI across the network.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Well. The most obvious answer would be to ask the original developer where he/she put them.

Perhaps the report files are stored on a repository server behind the web-server. It's quite common you know.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Like I said. The second solution would be to use the file manipulation tools in VB.NET code, but to run the program itself as an administrator (run as).
I haven't tried it, though.
I found this article explaining how to auto-elevate a program within the bounds of the UAC: http://archive.msdn.microsoft.com/KB981778

The tools available to you are in the IO namespace.
File.Copy(), File.Move() a.s.o.

Oxiegen 88 Basically an Occasional Poster Featured Poster

The System32 folder is managed by the UAC.
So in order for you to copy a file to that folder you have to use an elevated process.

If you go with the CMD.exe thing, you can elevate the process to administrator. Maybe this will help.

Dim process As New Process()
process.StartInfo.FileName = "cmd.exe "
process.StartInfo.Verb = "runas"
process.StartInfo.UseShellExecute = True
process.Start()

Another method that might help is if you use VB.NET tools only to copy the file, and run the entire project in an elevated state.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Have you looked at the key-binding settings?
Perhaps the new updates included either a reset or a new binding for Alt+S.
Have a look at this: http://superuser.com/questions/565520/how-to-modify-key-bindings-in-windows-8

Oxiegen 88 Basically an Occasional Poster Featured Poster

This might be of some assistance.
A tab consists of a certain number of blank spaces, if one field just happens to have that number of spaces without being a tab that might cause the problem you're having.

You may have to include some double cheching to compare the text of each field using both the original and the new csv.
Also, check to see if one or more of the fields contain a single-quote.

Oxiegen 88 Basically an Occasional Poster Featured Poster

I would start with taking a look at the namespace System.IO.
It contains a whole bunch of classes for reading files.
System.IO.StreamReader is one of those classes, which also happens to contain a method called ReadLine().
Combine that with a While loop and off you go. :)
Perhaps this thread could be of some help.

And depending on how those columns in the textfile are separated perhaps you should also dig into how to read CSV files.

From there it's quite a small step to separate the file's content into proper containers.

Oxiegen 88 Basically an Occasional Poster Featured Poster

If you create and add controls through code then those controls will not have any events tied to them.
When you open the second and third panels and create controls in them, you also have to use the AddHandler statement and tie that to the txbUM_KeyDown event, or use a generic event and tie all three textboxes to it using AddHandler.

'For panel 2
AddHandler txbUM2.KeyDown, AddressOf txbUM_KeyDown

'For panel 3
AddHandler txbUM3.KeyDown, AddressOf txbUM_KeyDown

Like that.
And in the event itself you can use sender to identify which textbox triggered the event by using CType.

Dim tbox As TextBox = CType(sender, TextBox)
Oxiegen 88 Basically an Occasional Poster Featured Poster

If I remember correcly, the thing about TCP connections is that they are only actually connected during a data transfer between the client and the server. And not while idle.

So my suggestion would be that you should check to see if there is a connection before trying to disconnect.
At least in order to avoid any embarrassing error messages. :)

Oxiegen 88 Basically an Occasional Poster Featured Poster

This will help with the moving part: http://www.daniweb.com/software-development/vbnet/threads/343625/runtime-draggable-panel

And this should give you some ideas with the "snap-to-grid" function: http://www.xtremevbtalk.com/showthread.php?t=236354

And last, I think that you can create the dragging icon by simply modifying the mouse cursor.
Here's an article on how to accomplish that: http://www.codeproject.com/Articles/33789/Custom-Mouse-Cursors-VB-NET

Oxiegen 88 Basically an Occasional Poster Featured Poster

Have you tried using the image as the forms background, instead of using pictureboxes?
Unless, of course, you're using the background to draw the ball.
That would be the reason for why the ball is behind the picturebox instead of on top of it.

Oxiegen 88 Basically an Occasional Poster Featured Poster

It could be some residual service still running that's part of the game.
Check the Task Manager to see if there's something that uses a lot of CPU and/or memory.

Oxiegen 88 Basically an Occasional Poster Featured Poster

If you name your picture boxes in such a way that it ends with a number from 0 to whatever, all you have to do is iterate through the rows in the table and assign each image to the pictureboxes.
Something like this:

Dim img As BitMap
Dim picboxIndex As Integer = 0
For Each row As DataRow In dt.Rows
    Dim mem As New IO.MemoryStream(CType(row("image field"), Byte()))
    img = Image.FromStream(mem)
    DirectCast(Me.FindControl("picBox" + picboxIndex), PictureBox).Image = img
    mem.Close()
    picboxIndex += 1
Next
Oxiegen 88 Basically an Occasional Poster Featured Poster

Add return false; in your javascript code after displaying the alert box.
That normally stops the form from submitting.

Oxiegen 88 Basically an Occasional Poster Featured Poster

If you disregard the time it takes to lift you hand from the keyboard in order to move the mouse the button.

You could do this more simpler by using javascript to time the keyboard interaction from the time the first character has been typed until a button has been clicked.
That would give you the exact time in seconds without having to calculate it using TimeSpan.

You can store the time ticks in a asp.net hidden field from the javascript code, and then read that value on postback.

A simple javascript stopwatch can be found here: http://www.codeproject.com/Articles/29330/JavaScript-Stopwatch

Oxiegen 88 Basically an Occasional Poster Featured Poster

When you postback a form to the codebehind, all the formatting is there (except font and color).
But for some reason the database/datatype sometimes has problems retaining those.

When I ran into this problem on a project once, I simply read all the text from the textbox/textarea into a string variable and at the same time replace all occurences of linebreak with a ¤ sign (shift + 4).

Now, almost everyone know that the ¤ sign is almost never ever used for anything useful at all. As far as I know. :)
So a single linebreak/carrier return equals one ¤ sign, and a double linebreak (a paragraph) equals two ¤ signs.

And when you later on read the information from the database, you simply reverse the replacement. Replace the ¤ sign with a linebreak.
In VB.NET that would be VbCrLf.

Also. Converting all that text into html could pose a problem for you, becuase for some reason ASP.NET has some kind of built-in feature that thinks that certain kind of posted back HTML code is harmful, and thus will cause an exception error.

A way around that, I think, is to delve deeper into string replacement and figure out a way to use a combination of replacement characters for certain fonts and colors and formatting.
Like the one here on DaniWeb. :)

Oxiegen 88 Basically an Occasional Poster Featured Poster

Still. To be on the safer side, it would be best to put the source files in the very permanent location of the users homefolder.
Don't you all agree? :)

Oxiegen 88 Basically an Occasional Poster Featured Poster

I cannot speak for all the webhosts in the world.
However, I would say that some webhosts provide such a solution, provided that you register a domain with them.
But most do not. They require that you order the full package of a webspace that includes 5, or more, email addresses.

But to answer your question.
Yes. It's possible.

How about this example? http://www.mailorderworks.co.uk/

Oxiegen 88 Basically an Occasional Poster Featured Poster

It could be anything from .NET 2.0 to 4.0.
You just have to run the program and see if you have the latest needed version of .NET.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Ok. Getting closer.
Now, like in the example you need to insert the line where you execute the reader just before WriteToServer.

sqlCommand.CommandText = removeCharacter;

//Execute reader here
excelReader = sqlCommand.ExecuteReader();

//Write to server here
sqlBulk.WriteToServer(excelReader);

excelReader.Close();
Oxiegen 88 Basically an Occasional Poster Featured Poster

Like JorgeM said. Suggestion 4 would be the best bet.
I've never even heard of gtb inspector. :)

Oxiegen 88 Basically an Occasional Poster Featured Poster

Well. It depends.
What kind of proxy server are you running?
MS? Linux? Hardware?

There are several suggestions in this thread, which is a linux based proxy.
And you can also read up on Web Proxy Autodiscovery Protocol.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Which files would that be?

If Windows start properly each time you boot up, then they aren't really missing.
You just can't see them.

If Windows won't start, perhaps there's a virus infecting/replacing/removing those files.

Oxiegen 88 Basically an Occasional Poster Featured Poster

The username is usually defaulted to admin.
And depending on the manufacturer of the router, the default password (unless changed) could be one of the following:
admin
password
1234
123456

Oxiegen 88 Basically an Occasional Poster Featured Poster

It's because you perform the sqlBulk.WriteToServer(excelReader) before you set the CommandText in the SqlCommand object.

Use the SqlCommand and construct your query and execute the reader first, and use WriteToServer last.

Examine this example: http://msdn.microsoft.com/en-us/library/434atets

Oxiegen 88 Basically an Occasional Poster Featured Poster

Have you looked at the AjaxToolkit ModalPopupExtender?
You can combine it with an UpdatePanel.

Oxiegen 88 Basically an Occasional Poster Featured Poster

I figured it out.
In the master page init event there was a call to a database query that, despite being extremely narrow using the WHERE clause, took too long.

I'll have to figure out a way to both keep the cake and eat it at the same time.
I need that query. :)

Oxiegen 88 Basically an Occasional Poster Featured Poster

I'm bumping this because I only got one reply that wasn't even helpful, nor provided an explanation to my problem.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Try removing the WiFi connection on your computer and re-discover it.
That has helped me many times, even if the connection worked the day before. :)

Oxiegen 88 Basically an Occasional Poster Featured Poster

Thank you for your response.
But I don't see how that could be the problem.

This occurs from the very start.
I'll boot up the computer, run Visual Studio, hit debug and presto! Very slow.
I've even tried publishing to the local IIS wwwroot folder and browse to the application as one normally would to any website. Same thing.

My default browser is Chrome, but I've tried using Firefox and Internet Explorer as well.
Same problem.

And by the way.
How do you close a connection to IIS from within an ASP.NET application?
That would be interesting to know. :)

Oxiegen 88 Basically an Occasional Poster Featured Poster

Hi.
I'm currently developing a CRM in ASP.NET 4.0. It has a database connection that resides on a separate computer.
The development and dev-hosting of the site is done locally.

Until yesterday everything worked almost flawlessly (except for those part I'm working on), but suddenly all postbacks and redirects slowed almost to a crawl.
And for the life of me I can't figure it out.

I read one blog that said that it's always a good idea to use the overloads for Response.Redirect, and to enter False as the second argument.
So, I changed those in some of the places and I noticed a slight difference in performance. But only when redirecting to a different page.
It's the postbacks that are killing me here.

I make frequent use of UpdatePanels and one of the pages do perform several queries against the database, but that has never been an issue before.

Has anyone any ideas of what the issue can be?

Oxiegen 88 Basically an Occasional Poster Featured Poster

The question mark (?) was just an indicator telling you to put a numeric value there.
A question mark is also known as an "unknown". :)

Auto is not a property, it's a valid value to simply allow the container to expand depending on whatever the size of the content without regards.

Oxiegen 88 Basically an Occasional Poster Featured Poster

True enough.
But it has to be agreed upon that both methods has their merrits and drawbacks.
My experience with using % is that things has a tendency to move around alot and not always staying in the shape or place I want them to. :)

It's fair to say that a container (body, div and so on) with a width set in % absolutely do adjust to any changes in resolution and/or browser window size.
But you also have to take into consideration the content within the container, and whether or not you care if it looks good on a cell-phone if you only target computer monitors.
In some instances it is justifiable to accept both vertical and horizontal scrollbars. Even if you don't like them. :)

So, my suggestion to rotten69 is to experiment with both techniques to see what suits you the best.

Oxiegen 88 Basically an Occasional Poster Featured Poster

It all pretty much comes down to screen resolution.
Which is a tricky thing to predict.
If your 10 inch monitor have a maximum resolution of 1024x768 pixels.
Then I would say that about 1000px is the maximum limit of the width that you can set.

Luckily CSS provides you with two tags that allows you to create a range of widths.
min-width
max-width

<body>
    <div style="min-width: 920px; max-width: 1000px; height: auto;">
        --- CONTENT ---
    </div>
</body>

But if you feel like experimenting a bit, then you can lock the width.
Replace ? with a numeric value.

<body>
    <div style="width: ?px; height: auto;">
        --- CONTENT ---
    </div>
</body>
Oxiegen 88 Basically an Occasional Poster Featured Poster

I only put auto on the height.
Because you stated that you wanted your design to look similar on other screens as it does on a 10 inch monitor.
Then you need to figure out what the optimum width is based on the smaller screen, but height should be set to auto because content has a tendency to grow vertically.

I showed two ways to do the same thing.

Oxiegen 88 Basically an Occasional Poster Featured Poster

Add a div and use it as a wrapper and put all the content in that.
You can use either an external CSS and create a class for the wrapper and state a width and height, or use an inline-style to state width and height.

<body>
    <div class="wrapper">
        --- CONTENT ---
    </div>
</body>

<body>
    <div style="width: ?px; height: auto;">
        --- CONTENT ---
    </div>
</body>