|
And what is the exception message that is thrown?
|
|
|
|
|
No value given for one or more required parameters.
|
|
|
|
|
I think you need to do an inner join on the tables. Like:
UPDATE OP_INFO
INNER JOIN REQ_INFO ON OP_INFO.OP_INDEX = REQ_INFO.REQ_INDEX
SET OP_INFO.OPINFO29 = [REQ_INFO].[NAME];
It’s not because things are difficult that we do not dare, it’s because we do not dare that things are difficult. ~Seneca
modified on Thursday, June 17, 2010 5:20 PM
|
|
|
|
|
That worked perfectly. Thank you
|
|
|
|
|
Great. I had the table name wrong on the left-hand side of the SET but fixed it!
It’s not because things are difficult that we do not dare, it’s because we do not dare that things are difficult. ~Seneca
|
|
|
|
|
Hi All,
I am trying to add a dropdown to a column in a datagridview. Below is the code I use to populate the Datagridview.
Can I just add something to this to make 2nd and 3rd column have a dropdown or do I need to take a completely different aproach to achieve this.
The data for the dropdown will be the same for each row and will be extracted from an existing table.
Any help would be greatly appreciated.
I am using VS2005.
Private Sub FillBinDataGrid()
Dim SqlBin As String = _
"SELECT zz_ST_Binsheets.iStockLink, zz_ST_Binsheets.iBinSheetLine, " _
& "StkItem.Code, StkItem.Description_1, " _
& "zz_ST_Binsheets.iPacksize, zz_ST_Binsheets.fQuantity " _
& "FROM zz_ST_Binsheets LEFT JOIN " _
& "StkItem ON zz_ST_Binsheets.iStockLink = StkItem.StockLink " _
& "WHERE zz_ST_Binsheets.iBinSheetNr = @binnr "
Dim Sqlparam As SqlClient.SqlParameter
Sqlparam = New SqlClient.SqlParameter("@binnr", SqlDbType.Int)
Sqlparam.Value = BsBinNrTextbox.Text
Dim Conn As New SqlConnection(CntString)
Conn.Open()
Dim MyCommand As New SqlCommand(SqlBin, Conn)
MyCommand.Parameters.Add(Sqlparam)
Dim adapter As New SqlDataAdapter(MyCommand)
Dim dtset As New DataSet
adapter.Fill(dtset)
adapter.Dispose()
Conn.Close()
Dim table As DataTable = dtset.Tables(0)
With Me.BsDataGridView
.DataSource = table
.AutoResizeColumns()
.Columns(0).Visible = False
End With
End Sub
|
|
|
|
|
You will need to add a DataGridViewComboBoxColumn to your DataGridView. You will also need to set its DataSource, DisplayMember and ValueMember.
|
|
|
|
|
Thanks for the response, I will play around with that and see if I can get it to work.
|
|
|
|
|
Hi all,
for quite a long time I try to solve some event issue, try tons of sample code but can't come to a working result. Can someone please help me get forward a bit?
In my application, which is organized as plugin framework, I'm meanwhile able to raise events inside a "pluginClass" (which is part of every plugin) and receive them in a main pluginhandler class. But what I need to do is reacting to an event (button click) from the plugin's main form (i.e. another class). My current approach is not working:
1. Add a handler to the pluginClass, which has a SendList method raising an own event
AddHandler frmMain.ListSend, AddressOf SendList
Public Sub SendList(ByVal sender As Object, ByVal e As IPluginEventArgs)
RaiseEvent ListFilled(Me, New IPluginEventArgs() With {.plugin = Me, .currentEventName = "ListFilled"})
End Sub 3. Raise the forms ListSend event in the forms' respective event handler (button.click)
RaiseEvent ListSend(Me, New IPluginEventArgs)
The forms ListSend event is raised, but obviously the pluginClass doesn't listen and/or call the 'SendList' method. Where am I going wrong? Any advice appreciated... I'm more and more confused... and a bit desperate already.
Thank you
Michael
|
|
|
|
|
when you declare frmMain in the class that you want to catch the event, did you declare it while using the keyword WithEvents ?
|
|
|
|
|
Thank you for your time, elliot.
No, I didn't. Unfortunately changing the declaration didn't make any difference. Here's how the pluginClass creates an instance of the form and puts it into a panel of the MDI form as a control:
Public Sub UpdateMDI(ByVal MDIForm As IPluginMDIForm) Implements IPlugin.UpdateMainWindow
If startedAsPlugIn = false then exit sub
m_mainform = New frmMain
With m_mainform
.TopLevel = False
.FormBorderStyle = FormBorderStyle.None
.Dock = DockStyle.Left
MDIForm.TargetControl.Controls.Add(m_mainform)
MDIForm.TargetControl.Visible = True
.Visible = True
AddHandler frmMain.ListSend, AddressOf SendList
End With
End Sub
Private WithEvents m_mainform As Form = frmMain
Public ReadOnly Property MainForm() As Form Implements IPlugin.MainForm
Get
Return m_mainform
End Get
End Property
modified on Thursday, June 17, 2010 11:18 AM
|
|
|
|
|
I'm confused......
Is;
a) frmMain generated by the pluginClass
or b) pluginClass being instanced by frmMain
[edit: change message type to question]
Dave
Don't forget to rate messages!Find Me On: Web| Facebook| Twitter| LinkedInWaving? dave.m.auld[at]googlewave.com
modified on Thursday, June 17, 2010 10:05 AM
|
|
|
|
|
Thank you for helping, Dave. And sorry if I didn't express clear enough.
The pluginClass generates an instance of the form. I posted the code into my above answer, would you be so kind as to have another look there (with respect to the thread lenght I didn't put it twice)?
Maybe my whole approach is a bit clumsy, but it works just the way I want it to. Every plugin is supposed to use a particular area in the MDI, arranged through panels and splitters. Once a plugin is called, it's forms are added the different panels as controls. With the help of the splitters the user is able to adapt the different forms (panels) to his current needs.
|
|
|
|
|
Michael,
I just setup a new forms project;
1) Created an MDI form that had a single Panel to act as the container for the plugin Form
In the mdi form load event i called a sub which created the plugin class instance;
Private Plugin As PlugInClass
Private Sub MDIParent1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
AddChildFormToPanel()
End Sub
Private Sub AddChildFormToPanel()
Plugin = New PlugInClass(Me.FormPluginContainer)
End Sub
2) Created a Plugin Class which instantiates the form and loads it into the panel of the mdiform, the class also has a sub which handles the forms event.
Public Class PlugInClass
Private WithEvents m_mainform As FormPlugin
Public Sub New(ByRef TargetPanel As Panel)
m_mainform = New FormPlugin
With m_mainform
.TopLevel = False
.FormBorderStyle = FormBorderStyle.None
.Dock = DockStyle.Left
TargetPanel.Controls.Add(m_mainform)
.Visible = True
End With
End Sub
Private Sub thePluginFormRaisedAnEvent() Handles m_mainform.ButtonPressed
MsgBox("The Plug In Form Raised An Event in the PlugInClass")
End Sub
End Class
3) Created a PlugIn Form with a single button, that raises an event when clicked.
Public Event ButtonPressed()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
RaiseEvent ButtonPressed()
End Sub
Ran the project, the form was created and loaded into the mdiform panel.
When the button is clicked the Class happily raises the message box.
I think this is what you are trying to do, and it appears to work just fine, although i didn't use any AddHandler calls, and passed in ByRef the panel where the form should be placed in the constructor for the class.
All appears to work fine.
|
|
|
|
|
Wow... that's exactly what I'm trying to do. So at least I was on the right track somehow
I'll sit down immediately, compare the differences and adapt my code. Let you know the result then! Thanks again - and for the big effort I'd really love to rate this advice with a double maximum
|
|
|
|
|
IT WORKS NOW
After adapting my code to yours I found that I might have a scope issue, since Intellisense didn't show me the form's event (ButtonPressed) when I wanted to put the "Handles" clause to my equivalent of your "thePluginFormRaisedAnEvent" method. Finally my error was (which was somehow to be expected ) a really silly thing:
The declaration of my m_mainform variable
Private WithEvents m_mainform As Form = frmMain 'not working is supposed to be
Private WithEvents m_mainform As frmMain
Would anyone guess such a silly little thing being a valley of pain?
Thank you for helping me find the right track!
|
|
|
|
|
Happy your happy!
|
|
|
|
|
We care trying to migrate from our current VisStudio 2005 (VB) on XP to 2008 or 2010 in Win7.
In some of our early test we see that the behavior is much different.
The one that is a killer is how errors are handled.
In VisStudio IDE if you get an error it stops message.
Given code
sub forms_load ...
dim i as short = 0
i = 1 / i (error divide by zero).
i = i
end sub
If the above is executed in IDE with 2005 you get a message on the i = 1 / 0. So you can fix it.
In 2008 and 2010 it just exits the function and the form is displayed (i = i is never executed).
If you put in a Try / Catch it does catch the error.
So how can we get it to stop with the error message and not just exit the function. There must be some option that we missed.
Also do you think that we should go 2010 or just 2008 and wait to see what shakes out?
Thanks
|
|
|
|
|
Hi,
I'll assume this is a WinForms app.
1.
The way some exceptions get handled by default is different when running inside or outside Visual Studio, and can be controlled by some Visual settings. Look at menu Debug/Exceptions...
2.
You should provide local try-catch for problems you can deal with locally.
3.
If all else fails, you can provide a safety net to your entire application; it will not be good enough to catch and solve the exception and continue execution in a meaningful way, it will however signal you something is wrong and needs a code fix. You would need at least two things:
- a try-catch in your main method, which is located in automatically generated file program.vb (may be hidden a bit).
- an event handler attached to Application.ThreadException; could also be added inside the same main method.
|
|
|
|
|
Yes it is a plain Windows App.
This does not answer the question about the behavior of 2005 vs 2010.
I know that a try / catch would catch it. But why doesn't it stop with an error just like 2005.
There must be a setting or something that would make it stop the same way otherwise migration of our large apps will be extremely difficult.
|
|
|
|
|
Change the operator from / to \.
dim i as short = 0
i = 1 \ i '(error divide by zero).
i = i
That will raise an exception which you can handle.
It’s not because things are difficult that we do not dare, it’s because we do not dare that things are difficult. ~Seneca
|
|
|
|
|
I know but in 2005 it stopped with an error now it just exit the function as if nothing is wrong.
This completely changes the behavior when we are testing. There must be a setting or something to make it work like 2005.
|
|
|
|
|
Have you set Option Strict to ON?
It’s not because things are difficult that we do not dare, it’s because we do not dare that things are difficult. ~Seneca
|
|
|
|
|
No, Option Strict prevents implicit changing of types i.e. Short to Int, etc.
We do not want this on. It is not on in 2005.
There must be some setting that tells VS IDE to just exit if there is an error.
|
|
|
|
|
There must be a setting or something.
Does anyone have any ideas?
This will prevent us from moving off of 2005 since the test behavior will be so different.
HELP!!!
|
|
|
|