|
I have a module in a VB.NET 2005 project that is part of a dll. This dll also holds many of my common objects across multiple solutions. This particular module has a routine that all my transactions to the server run through.
Since other dll's and the main project of my solution each have a reference to this module, is it shared? Or does each dll have a separate instance?
The reason I need to know is because I want to set a flag in the module that says each subsequent transaction should not be treated as a "sync point" by the server (sometimes these same transactions may be a sync point elsewhere in the program). After the user has confirmed the actions they've taken, I would reset this flag and subsequent transactions would again be sync points. This allows me to easily "rollback" to the state prior to when the user performed the several transactions if they decide not the confirm.
So if I call the module from the main program, but transactions get called from the other various dlls that have their own reference to the module, will the setting of the flag be set by every transaction?
I realize a module is like a shared class but I'm unsure if .NET makes separate single copies for each dll and program that has a reference, or just one per solution? Any clarification would be sincerely appreciated.
|
|
|
|
|
A running program has no concept of Visual Studio solutions. Instead you should think in terms of processes and AppDomains. Each AppDomain (every process gets a separate one by default and may create more) gets its own "instance" of a static class[^].
So as long as your main programs and dlls are all running in the same AppDomain in the same process, you will have a single instance used by all of them.
|
|
|
|
|
how to clear session values when we close the browser in vb.net.
please give me immediate response.
modified on Monday, February 23, 2009 1:16 AM
|
|
|
|
|
I don't think you will get a prompt response (if at all) to your question given your demand!
How about looking up the documentation relating to sessions.......
|
|
|
|
|
You are an idiot, you are rude, and you are in the wrong forum.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
You really need to read up on ASP.NET and Sessions. There is no way for you ASP.NET code (which runs ENTIRELY on the server) to know if the user closes the browser.
|
|
|
|
|
how to unload and load a form?
|
|
|
|
|
Hello,
I'm not sure what you want is something like this:
Dim Newform1 as new Form1
Newform1.show() ' To Load a form
Newform1.Close() 'To Unload
'Or
Newform1.Hide() 'To Unload
I just hope it helps you.
modified on Monday, February 23, 2009 1:17 AM
|
|
|
|
|
yes..dats rite!!..but the form will restart,rite?..i dont want the form to restart..
plss...help me..txx
|
|
|
|
|
Form.Close() will close the form, it will not restart.
|
|
|
|
|
ya2..but actually i want to reset the form by unload n load back the form..can u help me?
|
|
|
|
|
Make your own reset method to reinitialize your objects and controls.
|
|
|
|
|
How many times are you going to ask the same question and ignore the answers you've been given?? There is no method to "reset" a form unless you write code to reset all of the values and controls you need, yourself.
If this is a child form you're talking about, all you need to do is create a new instance of the form, show it, get the values you need from it, then call Dispose on that instance. Every new instance you create will be created with the same initial values you specify in it's design and startup code.
|
|
|
|
|
Hi all,I'm having problem here with my code. I would like to Update the Database with my DataGridView1 when Click the Button1. But from the code below,I found that an Error have occured.
Error from Visual Studio 2008= System.Data: Missing the DataColumn 'DO_No'in the DataTable 'Main_table' for the SourceColumn 'DO_No'.
The following are the code I load the data from database to my DataGridView1:
Private Sub MaintainDO_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ObjMyConn = New MySqlConnection(MyConnString)
SQL = "SELECT * FROM main_table"
Try
ObjMyConn.Open()
ObjAdapter = New MySqlDataAdapter(SQL, ObjMyConn)
ObjComBuilder = New MySqlCommandBuilder(ObjAdapter)
ds = New DataSet
ObjAdapter.Fill(ds, "Main_table")
dt = ds.Tables("Main_table")
dt.Columns(0).ColumnName = "Date"
dt.Columns(1).ColumnName = "DO No."
dt.Columns(2).ColumnName = "Lorry No."
dt.Columns(3).ColumnName = "Load From"
dt.Columns(4).ColumnName = "To Site"
dt.Columns(5).ColumnName = "Company Name"
dt.Columns(6).ColumnName = "Item Description"
DataGridView1.DataSource = dt.DataSet.Tables("Main_table")
DataGridView1.Refresh()
Catch ex As Exception
MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OkOnly)
Finally
ObjMyConn.Close()
End Try
End Sub
The code I put inside my Button1:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SQL = "SELECT * FROM main_table"
Try
ObjAdapter.Update(ds.Tables("Main_table")) '<< Here is how I used to update my database.
ds.Tables("Main_table").Clear()
DataGridView1.DataSource = Nothing
DataGridView1.Refresh()
ObjMyConn.Open()
ObjAdapter = New MySqlDataAdapter(SQL, ObjMyConn)
ObjComBuilder = New MySqlCommandBuilder(ObjAdapter)
ObjAdapter.Fill(ds, "Main_table")
dt = ds.Tables("Main_table")
dt.Columns(0).ColumnName = "Date"
dt.Columns(1).ColumnName = "DO No."
dt.Columns(2).ColumnName = "Lorry No."
dt.Columns(3).ColumnName = "Load From"
dt.Columns(4).ColumnName = "To Site"
dt.Columns(5).ColumnName = "Company Name"
dt.Columns(6).ColumnName = "Item Description"
DataGridView1.DataSource = ds.Tables("Main_table")
DataGridView1.Refresh()
Catch ex As Exception
MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OkOnly)
Finally
ObjMyConn.Close()
End Try
End Sub
Besides,I have a few other question to know more about my coding style suits my need of the project. This are my question:
1. Am I using a right way to put the data into the datagridview? Any other way is better for me to control the data inside the datagridview?
2. If I need to add another column which shows abit calculation (suck like column1 x column2=>>new column9)into the datagridview,how should I do?
Thanks for reading my post,hope someone can give me some sample for this solution. Thank you again~!
|
|
|
|
|
OK. I think it's pretty obvious just by reading the error message. You're missing a column in your DataTable("Main_table") that you included in your SQL statement.
|
|
|
|
|
Thanks Mr. Dave,I have solve the problem. I make a mistaken on the DataGridView1.Column1 header name. So I change it to the original name and it works now.
Thanks alot to Mr. Dave and everyone reading here.
Regards
Drex
|
|
|
|
|
hii all..how to type a label vertically?
|
|
|
|
|
Change the label to a graphic and rotate the graphic
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
actually i want to do is the label can be display like this:
L
A
B
E
L
1
instead of LABEL1
by the way..thanks alot for your help..
|
|
|
|
|
well I'm sure you can alter the code from those articles.
My first idea would be to make a custom control inherited from label.
Then on the textchanged event set the height of the label (and width)
Then draw the every letter (make an array with the split function) on the control.
Haven't done it myself but it shouldn't be that hard to do.
If I have time I'll see what I can come up with once I'm home
|
|
|
|
|
oke thanks..but i dnt know how to do that.. ,but i will try tonite,,thanks alots,,have a nice day!!!
|
|
|
|
|
Public Class VerticalLabel
Inherits Label
Public Sub New()
Me.AutoSize = False
End Sub
Public Overrides Property AutoSize() As Boolean
Get
Return MyBase.AutoSize
End Get
Set(ByVal value As Boolean)
MyBase.AutoSize = False
End Set
End Property
Protected Overloads Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Dim graphics As Graphics = e.Graphics
Dim text As String = Me.Text
Dim width As Integer = 0
Dim height As Integer = 0
Dim textBrush As Brush = New SolidBrush(Me.ForeColor)
For Each c As Char In text.ToCharArray()
Dim sw As Single = graphics.MeasureString(c, Me.Font).Width
If sw > width Then
width = sw
End If
Dim sh As Single = graphics.MeasureString(c, Me.Font).Height
height += sh
graphics.DrawString(c, Me.Font, textBrush, 0, height - sh)
Next
Me.Width = width
Me.Height = height + 2
End Sub
Private Sub VerticalLabel_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.TextChanged
Me.Refresh()
End Sub
End Class
This should do what you want (very basic so you might want to add a bit, like an option to set it to vertical or horizontal,...)
|
|
|
|
|
oke, how about multiple label???
|
|
|
|
|
????? multiple label?
I gave you a custom control just copy past the code into an empty class file.
Build you solution and you'll have an extra control in you toolbox which you then can drag onto you form as many times as you want
|
|
|
|