cgeier 187 Junior Poster
cgeier 187 Junior Poster

The reason for your error is because Mid throws an error if the value of start is < 1.

Mid Function

start: Character position in string at which the part to be taken begins.

InStrRev Function

Usage: InStrRev(string1, string2[, start[, compare]])

string1: Required. String expression being searched.

string2: Required. String expression being searched for.

...

InStrRev returns a value of 0 if string2 is not
found.

Stuugie commented: Thanks for clarifying why the MID Function errored out. +0
cgeier 187 Junior Poster

Try deleting the following code (lines 15-17):

if (LCase(Mid(objFile.Name, InstrRev(objFile.Name,"."))) = ".jpg") then
    oFile.Write objFolder & objFile.name & vbCrlf
end if

and replace it with this:

if (LCase(objFSO.getextensionname(objFile)) = "jpg") then
    oFile.Write objFolder & objFile.name & vbCrlf
end if

Resource:
VBScript: how do I determine file extensions?

The following may also be of interest:
Display All the Subfolders Within a Folder Using VBscript

Stuugie commented: Thanks for this help, I really appreciate it. +5
cgeier 187 Junior Poster

Test the hard drive to make sure it's not bad.

cgeier 187 Junior Poster

%5B, %5D, %3D are ASCII values.

%5B = '[' (left square bracket)
%5D = ']' (right square bracket)
%3D = '=' (equals)

ASCII Table

Below is a method of extracting the data:

string inputData = @"SearchOrder=2&Start=0&Count=-1&Query=(%5BDoc_Name%5D%3DABC+OR+%5BArea%5D%3DXYZ+OR+%5BSubArea%5D%3DQRS)";

string area = string.Empty;
string docName = string.Empty;
string subArea = string.Empty;
string userParams = string.Empty;

//get substring that contains the parameters
userParams = inputData.Substring(inputData.IndexOf("%5BDoc_Name%5D%3D"));

//get value for DocName
docName = userParams.Substring(userParams.IndexOf("%5BDoc_Name%5D%3D") + "%5BDoc_Name%5D%3D".Length, userParams.IndexOf("+OR+%5BArea%5D%3D") - (userParams.IndexOf("%5BDoc_Name%5D%3D") + "%5BDoc_Name%5D%3D".Length)).Trim();

//get value for Area
area = userParams.Substring(userParams.IndexOf("%5BArea%5D%3D") + "%5BArea%5D%3D".Length, userParams.IndexOf("+OR+%5BSubArea%5D%3D") - (userParams.IndexOf("%5BArea%5D%3D") + "%5BArea%5D%3D".Length)).Trim();

//get value for SubArea
subArea = userParams.Substring(userParams.IndexOf("%5BSubArea%5D%3D") + "%5BSubArea%5D%3D".Length, userParams.IndexOf(")") - (userParams.IndexOf("%5BSubArea%5D%3D") + "%5BSubArea%5D%3D".Length)).Trim();

The above code is difficult to read, however. So to make it a little easier to read, one could decode the URL before processing it. To do this, one can use:
HttpUtility.UrlDecode Method

This will change:

SearchOrder=2&Start=0&Count=-1&Query=(%5BDoc_Name%5D%3DABC+OR+%5BArea%5D%3DXYZ+OR+%5BSubArea%5D%3DQRS)

Into:

SearchOrder=2&Start=0&Count=-1&Query=([Doc_Name]=ABC OR [Area]=XYZ OR [SubArea]=QRS)

Note: HttpUtility.UrlDecode is not in the client version of .NET 4.0. If using, .NET 4.0, one needs to use the full version.

To use System.Web.HttpUtility.UrlDecode:

Add Reference to System.Web:

  • Click "Project" (in menu bar)
  • Select "Add Reference"
  • Click ".NET" tab
  • Select "System.Web"

Add using statement:

  • using System.Web;

Then, the process is similar to the above code:

string inputData = @"SearchOrder=2&Start=0&Count=-1&Query=(%5BDoc_Name%5D%3DABC+OR+%5BArea%5D%3DXYZ+OR+%5BSubArea%5D%3DQRS)";

string area = string.Empty;
string decodedUrl = string.Empty;
string docName = string.Empty;
string subArea = string.Empty;
string userParams = string.Empty;

//decode inputData and put result in decodedUrl
decodedUrl = …
cgeier 187 Junior Poster

You need help or you need someone to do it for you? If you need help, post the code that you have so far.

cgeier 187 Junior Poster

Knowing what controls are on your form would be beneficial. The easiest way is probably to change the text on the control.

cgeier 187 Junior Poster

Two possibilities that I see:

Possibility 1: recNo.Length is only allowing 1 iteration (as others have stated)

Try outputing the value of k: MessageBox.Show("k: " + k);

Possibility 2:
Receiving error because SqlParameter(s) is/are already declared. This should produce an error. However, if one did the following (or some version of it):

Try

...code...

Catch ex as Exception

End Try

The error may not show--because exception handling was added but basically the exception was discarded (no code exists to handle the exception).

Solution to possibility 2:

With cmdUpdate
    .Parameters.AddWithValue("@status", "A")
    .Parameters.Add("@recno")
End With

For k = 0 To recno.Length - 1
    sqlUpdate = "UPDATE shipment SET status=@status WHERE recno=@recno"

    'for debugging purposes
    MessageBox.Show("k: " & k & " recno val: " & recno(k))

    With cmdUpdate
        .Parameters("@recno").Value = recno(k)

        .CommandText = sqlUpdate
        .Connection = conn
        .ExecuteNonQuery()
    End With
Next

Additionally, eliminate any discarded exceptions--ensure that some sort of error message is issued when an exception occurs.

cgeier 187 Junior Poster

Check the value "progress". Can also try adding "refresh" after "xProgressBar1.Value = e.ProgressPercentage". If you are using a StatusStrip, call StatusStrip1.Refresh().

cgeier 187 Junior Poster

class FileWriter

-FileWriter(File file, boolean append)

Change line #21 (above) from:

FileWriter fw = new FileWriter(file.getAbsoluteFile());

To:

FileWriter fw = new FileWriter(file.getAbsoluteFile(),true);
cgeier 187 Junior Poster

You can try adding an application manifest to your project (as in UAC Troubles above).

Click "Project" (in menu bar)
Select "Add New Item"
Select "Application Manifest File"
Click "Add"

Try changing:

<requestedExecutionLevel level="asInvoker" uiAccess="false" />

To:

<requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />

If that doesn't work, you may also look into changing "uIAccess" from false to true.

Step 6: Create and Embed an Application Manifest (UAC)

uiAccess Values:

False: The application does not need to drive input to the user interface of another window on the desktop. Applications that are not providing accessibility should set this flag to false. Applications that are required to drive input to other windows on the desktop (on-screen keyboard, for example) should set this value to true.

True: The application is allowed to bypass user interface control levels to drive input to higher privilege windows on the desktop. This setting should only be used for user interface Assistive Technology applications.

*Note: Applications with the uiAccess flag set to true must be Authenticode signed to start properly. In addition, the application must reside in a protected location in the file system. \Program Files\ and \windows\system32\ *

Also, \Program Files (x86)

And from:
Windows Integrity Mechanism Design

By specifying UIAccess=”true” in the requestedPrivileges attribute, the application is stating a requirement to bypass UIPI restrictions on sending window messages across privilege levels. Windows Vista implements the following policy checks before starting an application with UIAccess privilege.

• The …

cgeier 187 Junior Poster

Here are some more that may be of interest:

Inside Windows 7 User Account Control

Tools List for Understanding Windows Integrity Mechanism (WIM)

Windows Integrity Mechanism Design

-User Interface Privilege Isolation (UIPI) and integrity
-UIAccess for UI automation applications

Mandatory Integrity Control in Windows 7 | 8

cgeier 187 Junior Poster
cgeier 187 Junior Poster

Are you running VS as an administrator? Try turning off UAC (under user accounts) before running your program and see if it works.

cgeier 187 Junior Poster

The following process is for use once you get your Win 8 working. But it states what size USB drive you will need. So, for WinPE 5.1, you will need 256 MB, but if you want to include the recovery partition on the drive (once Win 8 is bootable), you will need 16 GB or larger.

Create a Recovery Drive in Windows 8

...the USB flash drive you choose to use will become a dedicated Recovery Drive - you won't be able to use it for anything else. In its base configuration, the contents of the Recovery Drive will require about 256MB of space. However, if you choose to include the OEM recovery partition, you'll need more space. Thus, if you are creating a basic Recovery Drive, you can use a 1GB USB flash drive. (If you have a smaller sized drive, from the old days, you could use it as well.) If you are going to add OEM recovery partition, you'll want at least a 16GB USB flash drive...

Creating Recovery Media for Windows 8 - Toshiba

Have you tried pressing F12 at boot time to access the recovery partition?

cgeier 187 Junior Poster

Buy two so you can have one for Win 5.1 PE or for use as a Win 8 recovery tool.

cgeier 187 Junior Poster

Open Sql Server Configuration Manager (for SQL Server 2008) and check that TCPIP is enabled.

Win 7:

  • Click Start
  • In "Search programs and files" textbox, type: SQLServerManager10.msc
  • Press "Enter"

Win 8:

  • In the search charm, under Apps type: SQLServerManager10.msc
  • Press "Enter"

Then,

  • Double-click "SQL Server Network Configuration"
  • Click "Protocols for SQLExpress" (where "SQLExpress" is the name of the instance that you are using)
  • Look at "TCP/IP". If disabled, right-click, and select "Enable". Then restart the MSSQL service (or reboot your computer).
cgeier 187 Junior Poster

You can just write it to a CD/DVD. Or I think there is one that you can download for a USB drive, but it will probably overwrite the USB drive. You can use tools like the following:

ImgBurn

ISORecorder

to burn the ISO to a CD/DVD. CDs and DVDs are typically cheaper to buy.

cgeier 187 Junior Poster

Download and run Memtest86+:

Download by looking under "Download (Pre-built & ISOs)".

Under "Memtest86+ V5.01", click on "Download - Pre-Compiled Bootable ISO (.zip)"

This will test your memory, and since the memory test requires use of the processor, it will make sure the processor works.

cgeier 187 Junior Poster

I wouldn't focus too much on the computer not booting linux. The version of linux you are using may not be supported on that computer.

cgeier 187 Junior Poster

What is the model number (or name) of the laptop?

cgeier 187 Junior Poster

Are you using SQL Server or SQL Server Express? If so, are you trying to connect to an instance on the new machine? If so, did you install the db software on the new machine and create the database?

cgeier 187 Junior Poster

You can try the following connection string:

public static string connectStr = @"Data Source='.\SQLExpress';Initial Catalog='DB1'; Integrated Security = True";

//public static string connectStr = string.Format("Data Source='.\\SQLExpress'; Initial Catalog=\'myDB\'; User Id=\'user1\'; Password=\'password\'");

//where .\SQLExpress2008 (serverName\DBInstanceName) 

//'Initial Catalog='database name'

//'Integrated Security=True' means that it uses Windows authentication 

SqlConnection connection = new SqlConnection(connectStr);
cgeier 187 Junior Poster
cgeier 187 Junior Poster

If your computer uses UEFI firmware, I suggest checking whether it is set for "UEFI boot" or "CSM boot".

It appears that "UEFI boot" is used with GPT and "CSM boot" is used with MBR.

See the above post "How to Check if Windows is Booted in UEFI or Legacy BIOS Mode".

And since you said that you "replaced the MBR", the disk partitioning may be messed up at this point. See the following:

Wiping Out Old GPT Data

"I've been seeing a new GPT problem crop up with increasing frequency: Disks that have been used with GPT (on a Macintosh, for instance) are being re-used with MBR (on a Windows or Linux system, for instance). There's nothing wrong with this practice, but there is a pitfall: Because the basic MBR data occupies just one sector, compared with several for GPT, using an MBR-only partitioning tool can leave the disk with both valid MBR data and mostly-intact GPT data. The GPT data will not have a valid protective MBR, and any software that adheres strictly to the GPT specification will therefore ignore the GPT data in favor of the MBR data; however, some utilities and OSes will use the GPT data in this case. This is true of GParted 0.5.2 and 0.7.0 (and probably others), for instance. (It prints a warning to the text-mode console from which it was launched, but if you run it from a GUI menu, you won't see this warning!)

Such disks can be …

cgeier 187 Junior Poster

Ensure that the processor fan is working and the vent ports are free of dust/dirt. Has this computer been overclocked?
If so, reset BIOS/UEFI firmware settings to the default values.

What model is this computer? Did it Win 8 come installed or was it upgraded? From some info I found on the internet, if the Toshiba Satellite came installed with Win 8, then it uses UEFI firmware, otherwise it uses BIOS.

Try turning computer on and pressing/holding F2 to get into the BIOS/UEFI firmware settings.

I'm not all that familiar with UEFI. From the (limited) research I have done, it appears that UEFI uses GPT (GUID Partition Table)--not MBR. To use MBR, one would need to choose CSM (Compatibility Support Module).

At this point, I suggest that you try booting using WinPE. See below "Demo 2: Installing Windows PE on a USB Drive".

The following resources may be of use:
Windows Setup: Installing using the MBR or GPT partition style

Applies To: Windows 8.1

When installing Windows on UEFI-based PCs using Windows Setup, your hard drive partition style must be set up to support either UEFI mode or legacy BIOS-compatibility mode.

For example, if you receive the error message: “Windows cannot be installed to this disk. The selected disk is not of the GPT partition style”, it’s because your PC is booted in UEFI mode, but your hard drive is not configured for UEFI mode. You’ve got a few options:

1. Reboot the PC in …

cgeier 187 Junior Poster

Have you tried using the API?

Instagram API

cgeier 187 Junior Poster

Why aren't old posts prevented from being commented on. Posts from 5+ yrs ago are being revived. I think that any post that has been inactive for 6 months or more should be closed and not accept any new comments.

cgeier 187 Junior Poster

Ensure that you have saved any data from the hard drive that is important before proceeding. Making a image of the hard drive can also be useful before attempting any os installation repairs.

One of the first things that should be done is to verify that the computer can boot. Booting from your hard drive is not necessary at this step. How is this done? Use a boot disk. Many free ones can be found on the internet (WinPE, Linux, etc). This will help to eliminate the possibility of hardware issues (motherboard, memory, etc).

After verifying the computer can boot from a boot disk (or USB bootable device), then you can run disk scanning software (such as chkdsk) on the hard drive.

If it is determined that the OS installation is the issue, it may be easier and require less time to re-install the OS. Since you don't have a recovery DVD, you can order one from the manufacturer, or may be able to purchase a Windows DVD from MS.

cgeier 187 Junior Poster

You haven't posted enough of your code. "File in use" errors are a result of a file being open, and trying to modify it when it has a lock on it. Therefore, you need to post the code that opens and uses the file.

cgeier 187 Junior Poster

Your page margins are subject to the limitations of your printer. Check what the minimum margins are for your printer. Also ensure you've specified the correct paper size.

cgeier 187 Junior Poster

C# is case-sensitive. Are you sure your teacher didn't specify you to use "Base"? You can use "Base"--capital "B". Although, I wouldn't recommend using a different case of a reserved word. It would be similiar to you doing the following:

string employee = "John";
string Employee = "Bill";
string eMployee = "Joe";
string emPloyee = "Jane";

All would be permitted, but will likely lead to confusion either for you or for someone who has to maintain your code.

Perhaps part of the lesson to be learned from your assignment is about the case-sensitivity of C#.

cgeier 187 Junior Poster

I have no idea what you're talking about. What are you trying to do?

cgeier 187 Junior Poster

If you are using IE11, add code for IE 11.

Case 11
    If IgnoreIDocDirective Then
        value = 11001
    Else
        value = 11000
    End If
cgeier 187 Junior Poster

Try the following:

Dim htmlElements As HtmlElementCollection

htmlElements = WebBrowser1.Document.GetElementsByTagName("button")

For Each element As HtmlElement In htmlElements

    MessageBox.Show("element name: '" & element.Name & "'   InnerText: '" & element.InnerText & "'" & "  Type: '" & element.GetAttribute("type") & "'")

    If element.GetAttribute("type") = "submit" Then
        element.InvokeMember("Click")
        Exit For
    End If
Next
cgeier 187 Junior Poster

I've never used ReportViewer, but I found this post:

set page layout for report viewer...

The following is converted and and adapted for VB .NET:

Dim myPageSettings As New System.Drawing.Printing.PageSettings()

myPageSettings.Margins =  New System.Drawing.Printing.Margins(0, 0, 0, 0)

Dim paperSize As System.Drawing.Printing.PaperSize = New System.Drawing.Printing.PaperSize()

'ToDo: update with the PaperKind 
'that your printer uses
paperSize.RawKind = System.Drawing.Printing.PaperKind.Letter

'paperSize.RawKind = System.Drawing.Printing.PaperKind.A4

myPageSettings.PaperSize = paperSize

'False for "Portrait"
'True for "Landscape"
myPageSettings.Landscape = False

Me.ReportViewer1.SetPageSettings(myPageSettings)

Me.ReportViewer1.RefreshReport()

However, it's untested, so not sure if it works or not.

cgeier 187 Junior Poster

Did you try booting into safe mode and accessing your usb device? You could also download a boot cd/dvd and burn it to cd/dvd which you may be able to use to boot your computer and then copy/burn your files from your usb device to a dvd. Ensure your dvd drive works first. If all else fails back up your personal data. If your computer is newer, you may be able to boot from your usb device that contains your os files. You need to change the boot order so the usb device is before the hard drive (in the BIOS).

cgeier 187 Junior Poster

Automate that process.

cgeier 187 Junior Poster

In your program? Or in another program?

cgeier 187 Junior Poster

Cookies are files and can also be deleted. A user should be able to delete any file on his/her computer--in my opinion. Efforts to prevent such deletion are typically found in malicious software. Additionally, if you place your file in a folder with the name of the software, users know that if they delete files for a program that the program may no longer work properly. If you or your company own the computer you can set up access restrictions. If the user accidently deletes the file containing information he/she entered, then re-prompt the user for the information and re-create the file. Alternatively, you could store the information in the registry.

cgeier 187 Junior Poster

Encrypt the data before saving it.

cgeier 187 Junior Poster

Use a file. Xml file would work well. Search how to read/write to an XML file. Or you can just save the connection information to a text file.

cgeier 187 Junior Poster

Use a pen and paper and step through your code to see what is happening--to see what the computer sees.

cgeier 187 Junior Poster

In my testing, I built a dll that opens a message box as you stated above. Then I added a reference to the dll, added an Imports statement. And used the dll. I updated the dll, and copied the new dll to the folder that contains the .exe file, then ran the .exe file again and the MessageBox contents were changed. Please provide more details about the process that you used.(step-by-step).

cgeier 187 Junior Poster

Is your program running as a service?

cgeier 187 Junior Poster
cgeier 187 Junior Poster

Add using statement:

  • using Microsoft.Win32;

Then to find out if it is 32-bit (x86) or 64-bit:

private string processorArchitectureKey = @"HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment";

private string productVersionKey = @"HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion";

Then:

string processorArchitecture = Registry.GetValue(processorArchitectureKey, "PROCESSOR_ARCHITECTURE", null).ToString();
Console.WriteLine("Processor Architecture: " + processorArchitecture);

string osVersion = Registry.GetValue(productVersionKey, "ProductName", null).ToString();
Console.WriteLine("OS: " + osVersion);
cgeier 187 Junior Poster

Where is your code running? On your computer? Are you trying to update a database on your computer and on the web server?

cgeier 187 Junior Poster

What is the project? What is the PhD in?

cgeier 187 Junior Poster

You can also try something like the following:

dgTranslog = New DataGridView()

Dim tbColDatePerformed As DataGridViewTextBoxColumn = New DataGridViewTextBoxColumn()


tbColDatePerformed.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
tbColDatePerformed.DataPropertyName = Nothing
tbColDatePerformed.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
tbColDatePerformed.HeaderText = "Date Performed"
tbColDatePerformed.HeaderCell.Value = "Date Performed"
tbColDatePerformed.Name = "tbColDatePerformed"
tbColDatePerformed.ReadOnly = False
tbColDatePerformed.Resizable = DataGridViewTriState.True
tbColDatePerformed.SortMode = DataGridViewColumnSortMode.NotSortable
tbColDatePerformed.Width = 110

dgTranslog.Columns.Add(tbColDatePerformed)

Repeat the above for each column.