|
Hi ,
I have a datagrid in which I have a button column 'Delete' that works by calling 'Ondatagrid_deleteCommand'.
My problems is when I try to delete a record by clicking on 'Delete' button in datagrid, I get the following error
"Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index "
I am clueless as to why this is happening since the same routine is working in other application which is exactly similar and ofcourse in which I am using a datagrid.
The sub for delete command is as follows:
**************************************************************************************************<br />
Sub DataGrid_DeleteCommand(sender As Object, e As DataGridCommandEventArgs)<br />
'Create the objects for the connection<br />
Dim myConnection As New SqlConnection(ReadDBConnectionString())<br />
Dim DeleteCommand As SqlCommand = new SQLCommand()<br />
Dim Transaction as SQLTransaction<br />
<br />
'Define the Query<br />
<br />
DeleteCommand.CommandText = "DELETE from chequedata where cheqregno= " &DataGrid.DataKeys(e.Item.ItemIndex)<br />
'Add the Parameters to the Query with the actual Value<br />
<br />
DeleteCommand.Connection = myConnection<br />
<br />
<br />
'Start Try Block<br />
Try<br />
'Open Connection<br />
myConnection.Open()<br />
'Begin Transaction<br />
Transaction = myConnection.BeginTransaction()<br />
'Tell Command Object which Transaction to use<br />
DeleteCommand.Transaction = Transaction<br />
'Execute the SQL Command<br />
DeleteCommand.ExecuteNonQuery()<br />
'Nothing happend - Commit Transaction<br />
Transaction.commit()<br />
'Show Message in Label<br />
lblMessage.Text = "Entry deleted"<br />
catch ex as Exception<br />
'Failure occured - Rollback Transaction<br />
Transaction.RollBack()<br />
'Write Message in Label<br />
lblMessage.Text = "Entry Not deleted"<br />
Finally<br />
'Close connection<br />
myConnection.Close()<br />
<br />
DataGrid.EditItemIndex = -1<br />
'Refresh the Grid and show changes<br />
RefreshGrid(Cint(ddlBranch.SelectedITem.Value),txtsearch.text)<br />
<br />
End Try<br />
End Sub<br />
***************************************************************************************************
Thankyou all for all the help. It is much appreciated.
Aartee.
...HE is watching Us All!
|
|
|
|
|
I wanted to make a vb application which would dial a telephone number using
the modem. When the person on the other end lifts up the telephone (answers
the phone), the application should start playing an audio file(eg. .wav
file).
The approach I took was using the Tapi. As my modem is connected to the
serial port on my computer I send AT commands to make the phone call . This
is working fine and the call is being placed.
I wanted to know whether this is possible at all? Whether I am approaching
the wrong way? If it is possible, then please give some suggestions or
samples(vb or vc). If it is not possible , then what is the best way to do
so
|
|
|
|
|
Hi,
After searching the web and finding nothing, I'm trying this forum to find some answers.
1) There is two type of hotfixes for Windows (type 1 and type 2). How can I get this type. Somebody know what I could check to get it.
Something like GetHotfixType(sHotfixPath) and return 1 or 2.
2) I need to get a DLL language but can hardly find informations about a way of doing it.
Sample code in any programming language would be appreciated. I need it for VB but it don't matter, I'm gonna do the conversion.
Thank you for replying. Any information is welcome.
|
|
|
|
|
1) There's no way to tell the difference since the difference was how the hotfix was installed, not what was installed.
2) That information is not stored in the .DLL at all. The final binary doesn't know anything of the language that it was written in.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I think my question #2 wasn't very clear but anyway thanks Dave for your reply. I finally end up with this function. I already had what I wanted in my API functions (GetFileVersion which is almost the same).
<br />
'Return the language codepage of the file.<br />
Public Function GetFileCodepage(r_sFilePath As String) As Long<br />
<br />
Dim lSetToZero As Long<br />
Dim lByteArrSize As Long<br />
Dim aByteArr() As Byte<br />
Dim lTransPtr As Long<br />
Dim lTransLen As Long<br />
Dim lCodepage As Long<br />
<br />
lByteArrSize = APiGetFileVersionInfoSize(r_sFilePath$, lSetToZero&)<br />
<br />
If lByteArrSize > -1 Then<br />
<br />
ReDim aByteArr(lByteArrSize)<br />
<br />
If ApiGetFileVersionInfo(r_sFilePath$, 0&, _<br />
lByteArrSize&, aByteArr(0)) Then<br />
<br />
If ApiVerQueryValue(aByteArr(0), _<br />
"\VarFileInfo\Translation", lTransPtr&, lTransLen&) Then<br />
<br />
ReDim aByteArr(lTransLen)<br />
ApiRtlMoveMemory aByteArr(0), ByVal lTransPtr&, lTransLen&<br />
ApiRtlMoveMemory lCodepage&, aByteArr(0), 2&<br />
<br />
GetFileCodepage = lCodepage<br />
<br />
End If<br />
End If<br />
End If<br />
<br />
End Function<br />
For question #1, it must be something in Hotfixes binaries that tells which type it is. I'm not sure there is no way. I'll keep searching.
|
|
|
|
|
This if from the Windows 2000 Hotfix Installation and Deployment Guide[^]:
Hotfixes are packaged in a self-installing format. There are two main types of hotfix installations:
The update installation
Use this type of installation to install Windows hotfixes on computers that are already running Windows 2000.
The combination installation
Use this type of installation to perform an unattended installation of Windows hotfixes in combination with Windows 2000 or the service pack (or both).
There is NOTHING in the binary to tell you which type of hotfix it is. This is because the only difference is in the command line switch that was used to install the hotfix. There is nothing in the binary that will tell you how it was installed.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
i want to get the harddisk and processor id in vb.net...
is that possible...as i am writing a security utility....please guide me..
|
|
|
|
|
Hello all this is my first post here , hehe...
I wrote a function that returns a datarow .The datarow was created and declared within the function(it is not public).My question is does the datarow that was declared within that function gets disposed automatically or am I ending up with an extra datarow residing within memory(the created datarow and the receiving datarow) ?
-- the function is short:
Public Shared Function getDrow()as DataRow
dim dr as Datarow
--creates the datarow
return dr
End Function
implementation:
dim o as Datarow = getDrow
|
|
|
|
|
well! for your information the variables exist in a function are diposed automatically by the .net garbage collector...
in technical way the .net memmorry management is non-deterministic i.e. dot net manages it automatically....
so you don't need to worry in the function case it will be disposed automatically.....
hope that helps
|
|
|
|
|
Thanks m8 , I guess it's only logical what you're saying , I just needed the feedbackup. Cheers !
|
|
|
|
|
It is impossible to "see" into another persons XP (home edition) session from your own loggon session on the same computer.
I am trying to create a program which will be able to log keys accross widows sessions. I have got as far as logging keys using user32.dll but leaving a keylogging program running then switching user will not work because of the above problem. Your own loggin is unable to recieve the raw ascii sent to the dll on the other persons session.
Therefore:
Is it possible to make a VB application act as part of the OS so as to make it possible to see over sessions. Or are there any other solutions?
Cheers
°[Halo]°
|
|
|
|
|
The only thing that can do that is a Windows Service. You'll have to write a low-level keyboard hook into the service to get the keyboard messages as they come out of the keyboard driver.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
So it's impossible to do this in VB?
°[Halo]°
Project Basilisk
|
|
|
|
|
Since you're asking this, I'm assuming your using VB6. VB6 can't target building a Service directly, so you have to use third party components to get it to work.
Low level keyboard hooks are also much more difficult to do in VB6.
VB.NET will target building a Service and can do keyboard hooking much easier than VB6. But, the ultimate is ease is done in C++.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have a form named form1 and it contains one AxWebBrowser control.
Here is the code:
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Close()
End Sub
I get the following error.
An unhandled exception of type 'System.ObjectDisposedException' occurred in system.windows.forms.dll
Additional information: Cannot access a disposed object named "Form1".
Note: if the AxWebBrowser control is not on the form then i do not get any error.
How do I close form1 with the AxBrowser on it? Thank you.
Jonathan Elsner
|
|
|
|
|
You should never close a form in it's Load event. You should be deteremining if the form should be loaded before you even attempt to load it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am getting the following error:
System.Runtime.InteropServices.COMException (0x800401F3): Invalid class string
at System.RuntimeType.GetTypeFromProgIDImpl(String progID, String server, Boolean throwOnError)
at System.Type.GetTypeFromProgID(String progID, String server, Boolean throwOnError)
generated by the following code:
Dim tServerType As Type
Dim RemoteServer As WMSServer
Try
tServerType = Type.GetTypeFromProgID("WMSServer.Server", <myserver>, True)
RemoteServer = Activator.CreateInstance(tServerType)
I imagine I have to register the progID on my server? Anything else? (details appreciated)
________________________________________________________________________
Dave
Y10K bug! Let's not get caught with our pants down **AGAIN**! (DC 02002)
|
|
|
|
|
I am basically very new to VB.Net and I'm having problems with concerning datagrids.
I am loading a datagrid with information queried from a database. I then want to access that information within the datagrid so I can perform calculations. Can anyone point me in the right direction?
|
|
|
|
|
email me ...nerushanmoodley@yahoo.com. will help you wit code
|
|
|
|
|
I am using a multiline textbox in my application. I write the data from the textbox to a multiline cell within a spreadsheet. Everytime the user hits enter within the textbox to drop to the next line, a square wingding appears at the end of each text within the cell.
I thought this could be an easy fix. So, I did a search to find the wingding within the corresponding column. However, to my surprise, it doesn't seem to be a registered wingding. It is something else.
When I copy the data, not the cell, to another cell, each item is put into its OWN cell. It is registering this geometric shape as the "ENTER" key. Any help would be greatly appreciated. Thanks.
Dizzle
|
|
|
|
|
You're not seeing a wingding. You're seeing a character that Excel doesn't use and the font Excel is using doesn't have any image for that character.
You're also assuming that the NewLine character sequence in VB is the same as Excel's. VB's default NewLine sequence is Carriage Return, move cursor to the beginning of the line, follow by a Line Feed, advance the paper up one line. Excel doesn't use this sequence in its worksheets. You're sending an extra character that Excel doesn't have a use for.
Before you send the textbox data to the Excel sheet, you need to replace either the CR or LF characters in your string with either just CR (vbCr) or just LF (vbLf). I can't remember which one Excel uses. You just have to try it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
This is the only line of code I have to move the data to the appropriate cell:
ws.Cells(iRow, 4).Value = Me.TextBox1.Value
In the TextBox1 properties I have simply set it to multiline and allowed the user to step to each line by hitting "enter."
I understand what you are suggesting. However, I tried it when I was using A listbox. It did not work then either. I had to do what I am "trying" to do with a textbox. The difference is, the textbox "items" are not seperated by "selection." They are seperated by the user hitting "enter" and stepping to the next line. When I use vbNewLine or vbCrLf it displays the same character.
Thanks a lot for your suggestions. However, do you have any other ideas?
Dizzle
|
|
|
|
|
Like I said, you can't use CrLf! You can only use Cr OR Lf between lines. I don't know which one Excel uses off the top of my head.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi
I had recently posted this, but I did not get the answer. Because I DO really need this problem to solve, I repeat it.
In vb6 I have an ImageList that a ListView is bound to it. It works quite fine when dealing with small (up to 1000) number of images. but when the number of images becomes larger, my program suddenly crashes: "This program has performed an illegal operation."
The code I used, is here:
<br />
It's in vb6.<br />
It is in a function that gets FilePath and adds it's icon to the ImageList.<br />
<pre><code><br />
hIcon = ExtractAssociatedIcon(0, LCase(FilePath), 1)<br />
If IsNull(hIcon) Then<br />
'Error <br />
Else<br />
Set Pic.Picture = Nothing<br />
DrawIcon Pic.hdc, 0, 0, hIcon<br />
Pic.Picture = Pic.Image<br />
End If<br />
ImageList1.ListImages.Add , , Pic.Picture<br />
GetImageLisIconIndex = ImageList1.ListImages.Count<br />
It is in a function that gets the FilePath and adds its icon to the ImageList.
Thanks in advance.
|
|
|
|
|
MohammadAmiry wrote:
I had recently posted this, but I did not get the answer.
Perhaps because you have no patience? I just got the email that said you replied to my post today!
Looking at your code, your calling ExtractAssociatedIcon, but I don't see any code that destroys the Icon handle when you're done adding it. DestroyIcon[^]
This COULD be the cause of your problem.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|