|
where does strCondition come from ? You could be open for SQL injection attacks.
This is a weird problem, that the method is shared should not cause this. Is this the only code that calls this method ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Depending on the application work flow, strCondition is hard-coded.
Yeah, the method is called from other pages too, with different strCondition that suits the requirement of that page.
Another weird thing is the exception does not happen all the time, it is random. And the whole application works fine in development environment, the problem only occurs in the deployment area. In development, my PC is the server, I open the page on my PC, and also in another PC in the LAN. I do not get the exception! urgh...
What could possibly be the cause.. Should I not use shared for the method?
Thanks
Yenyen
|
|
|
|
|
Shared really can't make any difference. The only way I can see for this to happen, is if you call it elsewhere, using these two strings, and they accidentally get concatenated.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi ,
Though I don't understand why you want Method to be Shared One
just try this sql ="" before setting sql strconnection.
sql = ""
sql &= "SELECT * FROM tDataEntry"
If strCondition <> "" Then
sql &= " WHERE " & strCondition
End IF
sql &= " ORDER BY DateTime DESC"
Thanks and Wishes
Navneet Hegde
Nashik(City Of Pilgrimage)
Develop2Program & Program2Develop
|
|
|
|
|
He wants it to be shared because it has no state, and there's no reason for him to create a class instance, to call it.
Navneet Hegde wrote: just try this sql ="" before setting sql strconnection.
If that works, it is indicative of a deeper problem, as his code does not concatenate strings, or store them.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
Thank you for your suggestions. I will try sql = "" as Navneet suggested and monitor the situation to see if the issue happens again.
Cheers!
Yenyen
|
|
|
|
|
Please tell me how to add form into tab control.
Thanks.
|
|
|
|
|
You cannot. You can define your form as a user control and host that control in a form, to make a form of it, or in your tab control.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
I have a class that refreshes a datagridview control. I can call this from various places including forms and it works. It is located in a module.
I have a 2nd module with a class that calls the refresh class from the 1st module and for some reason i can do nothing with the data grid view. Msgbox tells me it is going into the refresh class but i cant even set the datagridview.row count to 0.
Example:
module functions
--Public Class DGV
----Public Shared Sub refresh()
Dim dataGV As DataGridView
dataGV = My.Forms.mainWindow.DataGridView1
dataGV.RowCount = 0
----end sub
--end class
end module
module runtime
--Public Class Watcher
----Public Shared Sub Run()
Call DGV.refresh()
----end sub
--end class
end module
Seems so simple but its killing me - from any form (button_click or form_load) it works fine over and over again. I reference it in a 2nd module and the datagrid does nothing... not clearing...
|
|
|
|
|
commieJerk wrote: ----Public Shared Sub refresh()
Dim dataGV As DataGridView
dataGV = My.Forms.mainWindow.DataGridView1
dataGV.RowCount = 0
----end sub
This is really nasty. Your code is strongly tied to a specific form, why would you call a dll, just to look for a form, and grab a UI element ( which really shouldn't be public anyhow ), and set a property on it ?
If you have a genuine need to do this in a function, pass the datagridrow into the function.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
ok yea I changed it to Public Shared Sub refresh(ByRef dataGrid As DataGridView).
I am just starting VB - coming from a VBA (access) background so im not used to a lot of basic programming stuff yet cause access does a lot of this stuff for you.
What i am trying to do in a nut shell is - using FileSystemWatcher(), update a datagridview when its change event fires. The problem is doing anything inside the event. I can put stops inside the refresh class and it seems to be clearing the datagridview and reloading the data but it dosent.
When I call the refresh class anywhere elese it works fine?
|
|
|
|
|
OK, this is the FileSystemWatcher that's firing an event ? I don't see any reason why code that's run in there would behave any differently. Is that code in a different dll to the main app ? b/c the main problem I'd expect is that you're updating the wrong datagridview - how do you access it ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
' Add event handlers.
<code>AddHandler watcher.Changed, AddressOf OnChanged</code>
' Define the event handlers.
<code>Public Shared Sub OnChanged(ByVal source As Object, ByVal e As FileSystemEventArgs)</code>
'OnChange gets fired twice for each update so make sure we only do stuff once.
<code>If bolChanged = False Then
Call DGV.refresh(My.Forms.mainWindow.DataGridView1)</code>
'this wont even run -> My.Forms.mainWindow.DataGridView1.rowcount=0
<code>bolChanged = True
ElseIf bolChanged = True Then
bolChanged = False
End If
End Sub</code>
|
|
|
|
|
Oh yea and even trying to set the text on a textbox wont work - but msgbox and the console work fine. Is this a limitation of the event sub?
|
|
|
|
|
Ok i found what i was doing wrong. I didnt realize the FileSystemWatcher event was on the .IO thread and to update a UI I had to use SynchronizingObject = My.Forms.mainWindow to update it. It works great now
|
|
|
|
|
my problem is i am about to enter new dates:
for example the new date is 6/6/2007 8:15:16
then i need to check if this new date will fall between an existing date...
existing date : 5/6/2007 8:23:54 and 7/6/2007 9:45:10
how could i be able to do that... can you give me a solution... i dont know if there is a predefined function for that...
thnx!
|
|
|
|
|
The < operator works with DateTime. So create your two range datetimes, and then check if your date > one and < the other. I'd write a helper function to do this.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello
I am trying to add a combo box to a datagridview, using the code below. However, i get the following error message: "Object reference not set to an instance of an object."
I also get this repeated message every few seconds. "The following exception occurred in the datagridview:
system.argumentException: Datagridviewcomboboxcell value is not valid.
To replace this default dialog please handle the dataerror event"
I haven't added the combo to the datagridview at design time, only in the code below.
Try<br />
'Fill the datagrid<br />
Me.TA_OrderSoftwarePart_dsCodeRed1.Fill(Me.DsAddComponetAndEquipment.OrderSoftwarePart)<br />
Me.dgvOrderSoftwarePart.DataSource = Me.bsOrderSoftwarePart<br />
<br />
Dim dgvc As DataGridViewComboBoxColumn<br />
dgvc = Me.dgvOrderSoftwarePart.Columns("Status")<br />
<br />
dgvc.Items.Add("To be Ordered")<br />
dgvc.Items.Add("Ordered")<br />
dgvc.Items.Add("Delivered")<br />
<br />
Catch ex As Exception<br />
MsgBox(ex.Message)<br />
End Try
Many thanks for any help with the code above,
Steve
|
|
|
|
|
I only had time for a quick look, but you created a reference to a POSSIBLE DataGridViewComboBoxColumn. You didn't actually create a new column. Change this line:
Dim dgvc As New DataGridViewComboBoxColumn
|
|
|
|
|
Hello,
I didn't use the new key word, as I don't want to create a new column but convert an existing column into a combo box column.
In my database table I have a column called status. This can be either "To be Ordered", "Ordered", or "Delivered".
So when datagridview displays in the form, it will allow the user to select either one of them.
Many thanks,
Steve
-- modified at 1:52 Wednesday 27th June, 2007
|
|
|
|
|
Well, that's where the "Object reference not set to an instance of an object" came from.
If I get your meaning, you can't change the type of the column once it's created. For example, you can't change a TextBoxColumn into a ComboBoxColumn. You can, however, hide the original TextBoxColumn, create an entirely new ComboBoxColumn, add it to the columns collection and setup it's properties to bind to the appropriate column in the dataset.
|
|
|
|
|
I've been trying to do the same thing. Could you post code for adding the ComboBoxColumn and binding it to the appropriate column in the dataset?
Thanks,
Diane Volk
|
|
|
|
|
Quick and dirty:
Dim col As New DataGridViewTextBoxColumn()
With col
.DataPropertyName = "Description"
.HeaderText = "Description"
End With
DataGridView1.Add(col)
|
|
|
|
|
This worked perfectly. I was missing setting the DataPropertyName in my code.
Thanks!
Diane Volk
|
|
|
|