|
Hi Friends, In my project, i am using two classes suppose A and B. Class A contains two functions suppose SetInputF1 and SetInputF2 with same code and same return type just differ in function name (both functions are used to assign input values of class A to static global variables), and class B contains one function suppose f3. SetInputF1 is called by many functions.
Now if i call SetInputF1 in f3 then the values of static global variables are not setting properly and if i call SetInputF2 in f3 then values are setting properly. I am using SetInputF2 function only due to this problem. But due to this my code length is increasing. How to overcome this problem , please help me if you can...
http://nnhamane.googlepages.com/
|
|
|
|
|
One more thing, SetInputF2 function is not called by any function. If i call SetInputF2 function in any other function then same problem occuring as with SetInputF1 function.
http://nnhamane.googlepages.com/
|
|
|
|
|
i think due to the cause of other functions your global variable values are changing.
better to clear those variables before calling your function.
|
|
|
|
|
I don't think you have a good understanding of the problem. Chances are one of the methods doesn't actually assign the static field under some circumstance, and you need to understand what those circumstances are in order to see how to proceed from here.
Also, I cannot help but wonder why you're using static fields. If they really belong to the class rather than an instance of the class then fine, but then you should also use static methods to work with the fields. Not that this would affect whether or not the fields get set; it just doesn't make any sense to require instance methods to be used to set class state - at least in most cases it wouldn't make sense.
The short answer to most questions of the sort "my code says to add together two and two and store the result in the variable 'n', but after the code has run the value of n is five. Why?" is "attach the debugger". Step through your code and step into the "SetF.." methods and inspect local, instance, and class variables, and you'll probably soon find out exactly why it doesn't work as expected, while at the same time learning invaluable debugging skills you can use to solve hundreds of other problems.
If that's not possible, post the minimum code required to reproduce the problem. If the problem is what you say it is, you should be able to reproduce it with simple classes a bit like this:
public class A
{
static int n;
static public void SetN(int value) { A.n = value; }
static public void GetN() { return A.n; }
}
I presume you have a way to GET the value that is being set as well, although I do not understand why you'd use this approach over static properties.
|
|
|
|
|
Thanks dojohansen for your reply. Actually static variables i have mentioned above are not actually variables..they work like static variables but they are objects of user defined classes(in dll) which are created for mapping the inputs, and the objects works as keys and can be used anywhere in the project. If i assign any input value to object then its value can be used throughout the program. So we use it...but sometimes value becomes undefined(error) as mentioned above. I thought that it was due to half code in .cpp and half in .h, so integrated all in .h file then also not working...while trying a lot i got the solution. I need to write same code with different function name and that function should not be called by any other function, then values are setting properly but code is increasing...dojohansen i have posted my query after lot of debugging and discussing with colleagues, hope you better understand my problem now. Thanks and Regards - Nilesh.
http://nnhamane.googlepages.com/
|
|
|
|
|
Is available, realised in language C # the project dll-components "Windows Forms Control Library" at which the main form is inherited from System. Windows. Forms. UserControl. Given a dll-component can display Tiff files. It is necessary to make so that in Internet Explorer at opening of the reference to a Tiff-file for file display it was used this mine of a dll-component as ActiveX.
For this purpose:
1. In Properties the project on a bookmark “Application\Assembly Information …” has established a tag “Make assembly COM-visible”, and on a bookmark “Build” - a tag “Register for COM interop”.
2. By means of a command “sn.exe-k ImagingSedoControl.snk” has created a file of keys and has placed on it the reference in file AssemblyInfo.cs of the project.
3. Has compiled dll-ku and then has placed assemblage in GAC. Thus in the register all necessary keys and sections were created.
4. Further being based on http://msdn.microsoft.com/en-us/library/aa751976 (VS.85).aspx has registered CLSID the basic class of component ImagingSedoControl. MainForm in section «HKEY_CLASSES_ROOT\MIME\Database\Content Type\image/tiff» in parametre CLSID.
After that Internet Explorer at opening of the reference to a Tiff-file, for example «C:\2886456.tiff», for its display began to load my component. But to display Tiff a file, in the basic class dll-components it is necessary for me to learn that line which has been entered in an address line Internet Explorer.
How it to make?
|
|
|
|
|
If you make a plug-in that handles a content type you do NOT need to know the URL of the resource, much less of the page containing it. That would only be useful for various sniffing or spying purposes.
The browser takes care of request and your component needs only the bytes that make up the response body. I wouldn't be surprised if plug-ins *can* obtain rather more information than this, but it's certainly all you need to draw the image.
|
|
|
|
|
The matter is that mine UserControl the component is Windows Form.NET the application, instead of component ASP.NET. This component is used as usual ActiveX Plugin adjusted for that it.NET a component. Clone of it is, for example Adobe Acrobat Pdf Plugin, which boots in Internet Explorer when in its address bar it is introduced, for example "C:\designpatternscard.pdf". It is obvious, that when Internet Explorer loads Adobe Acrobat Pdf Plugin it somehow transmits it string "C:\designpatternscard.pdf" since. Otherwise Adobe Acrobat Pdf Plugin "would not know" which file to it it is necessary to map.
|
|
|
|
|
I've never made any IE plugins and don't know the architecture, so I cannot claim how it actually works. However, there is certainly no need for the plug-in to know about the location of the file, or even it's name. The content of the file is enough.
However, rather than argue with your logic I'll try to point you in the direction of a solution: Have a look at SpicIE[^], the "Simple Plug-In Creator for Internet Explorer" project. It should give you everything you need and more.
|
|
|
|
|
Is it possible to detect that a file in a project is saved from a VS2005 add-in?
|
|
|
|
|
As from any program, you can detect that using a FileSystemWatcher. This won't indicate if the file changed in Visual Studio or somewhere else, but it will give you a notification whenever the file changes on disk.
Also, depending on what your plug-in is, it may be that it should not be a plugin at all but rather a "custom tool". If so, VS will re-run the tool whenever a file associated with the tool is saved. Look for example at the Coco/R for Visual Studio article here on CP.
|
|
|
|
|
I am not getting my program to update my access 2003 database. What the hek am I doing wrong.
This is the only problem that I still have in my program
Here is my code (function)
Public Function Edit() As String
Try
Dim OleDbConn As OleDbConnection = New OleDbConnection(ConnString)
OleDbConn.Open()
Dim MyOledbCommand As OleDbCommand = New OleDbCommand()
Dim String1, String2, String3, String4, String5, string6, string7, string8, string9, string10, string11, string12, string13 As String
String1 = TxtLuidraad.Text
String2 = txtA1.Text()
String3 = txtA2.Text()
String4 = txtA3.Text()
String5 = txtA4.Text()
string6 = txtA5.Text()
string7 = txtA6.Text()
string8 = txtA7.Text()
string9 = txtA8.Text()
string10 = txtA9.Text()
string11 = txtA10.Text()
string12 = txtA11.Text()
string13 = txtA12.Text()
MyOledbCommand.CommandText = "UPDATE Tblokkies SET WHERE leidraad = ?, A1 = ?, A2 = ?, A3 = ?,A4 = ?, A5 = ?, A6 = ?, A7 = ?, A8 = ?, A9 = ?, A10 = ?, A11 = ?, A12 = ?"
MyOledbCommand.Parameters.AddWithValue("@string1", Me.TxtLuidraad.Text)
MyOledbCommand.Parameters.AddWithValue("@string2", Me.txtA1.Text)
MyOledbCommand.Parameters.AddWithValue("@string3", Me.txtA2.Text)
MyOledbCommand.Parameters.AddWithValue("@string4", Me.txtA3.Text)
MyOledbCommand.Parameters.AddWithValue("@string5", Me.txtA4.Text)
MyOledbCommand.Parameters.AddWithValue("@string6", Me.txtA5.Text)
MyOledbCommand.Parameters.AddWithValue("@string7", Me.txtA6.Text)
MyOledbCommand.Parameters.AddWithValue("@string8", Me.txtA7.Text)
MyOledbCommand.Parameters.AddWithValue("@string9", Me.txtA8.Text)
MyOledbCommand.Parameters.AddWithValue("@string10", Me.txtA9.Text)
MyOledbCommand.Parameters.AddWithValue("@string11", Me.txtA10.Text)
MyOledbCommand.Parameters.AddWithValue("@string12", Me.txtA11.Text)
MyOledbCommand.Parameters.AddWithValue("@string13", Me.txtA12.Text)
MyOledbCommand.Connection = OleDbConn
MyOledbCommand.ExecuteNonQuery()
OleDbConn.Close()
DisableTextboxes()
NeroBar1.Value = 0
FillDataGrid("Select * from Tblokkies")
FillListBox("Select * from Tblokkies")
btnaddNew.Enabled = True
btnDelete.Enabled = True
' btnupdate.Enabled = True
SaveOrEdit = "Cancel"
'StatusLabel.Text = " Inligtin Verander."
StatusLabel.Text = "Leidraad :" & TxtLuidraad.Text & ": Verander."
Catch err As System.Exception
StatusLabel.Text = err.Message
End Try
End Function
My update button
Private Sub btnupdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnupdate.Click
StatusLabel.Text = " Kies Leidraad om te verander"
If ListBox1.SelectedIndex <> -1 Then
SaveOrEdit = "Edit"
Else
StatusLabel.Text = " Bestaande leidraad is nie verander nie"
End If
End Sub
My save button
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
If SaveOrEdit = "Save" Then
Dim add As DialogResult
add = Cls_MessageBbox.Show("Is jy Seker jy will Leidraad" & Environment.NewLine & TxtLuidraad.Text & Environment.NewLine & "Byvoeg", "Byvoeg.", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
AddNew()
'add = Cls_MessageBbox.Show("Leidraad" & Environment.NewLine & TxtLuidraad.Text & Environment.NewLine & "is Bygevoeg", "Byvoeg.", MessageBoxButtons.OK, MessageBoxIcon.Information)
ElseIf SaveOrEdit = "Edit" Then
Edit()
Else
StatusLabel.Text = " Geen Leidraad is bygevoeg"
End If
End Sub
|
|
|
|
|
hendrikbez wrote: MyOledbCommand.CommandText = "UPDATE Tblokkies SET WHERE leidraad = ?, A1 = ?, A2 = ?, A3 = ?,A4 = ?, A5 = ?, A6 = ?, A7 = ?, A8 = ?, A9 = ?, A10 = ?, A11 = ?, A12 = ?" MyOledbCommand.Parameters.AddWithValue("@string1", Me.TxtLuidraad.Text)
Okay - at least part of your problem lies here. You use positional parameters (?) in your statement, but named parameters in your parameters list. They need to be consistent.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
even if I use this
MyOledbCommand.CommandText = "UPDATE Tblokkies SET leidraad = @string1, A1 = @string2, A2 = @string3, A3 = @string4,A4 = @string5, A5 = @string6, A6 = @string7, A7 = @string8, A8 = @string9, A9 = @string10, A10 = @string11, A11 = @string12, A12 = @string13"
I can not get it to save to the database
|
|
|
|
|
I think that the WHERE part would be moved to the end of the statement, and you might want to check the parameters;
"UPDATE Tblokkies
SET A1 = @string2,
A2 = @string3,
A3 = @string4,
A4 = @string5,
A5 = @string6,
A6 = @string7,
A7 = @string8,
A8 = @string9,
A9 = @string10,
A10 = @string11,
A11 = @string12,
A12 = @string13
WHERE leidraad = @string1" Enjoy
I are troll
|
|
|
|
|
Thanks, now I am getting a answer back, that it did not save it to database,
before, I did not get anyting back
Edit
Ps sometimes it says that is have saved the info, but there it did not sdaved it in the data base
|
|
|
|
|
hendrikbez wrote: Ps sometimes it says that is have saved the info, but there it did not sdaved it in the data base
That might happen when there are no records matching the parameter @string1 ; in that case it will return with succes, since it updated all records matching the criteria (iow, no records at all).
Try the query outside of your code, and verify whether it works as intended
I are troll
|
|
|
|
|
My string1 and string2 will always have info in, I only want to add string3 today, and later string4 and so on, so when I click on my listbox it chooses the info and put it in my textboxers, then I add a new word to string3, then it must update, but it don't
|
|
|
|
|
It will only update the row in the table that has "@string1". That means that the row has to exist before you can update it. Can you put a breakpoint there and verify that "string1" is filled with the correct key?
In other words, I'm interested in the values that you're writing to the database.
I are troll
|
|
|
|
|
With my Breakpoint.
1. Click on button "Edit info"
2. Say I must choose a leidraad to edit
3. Choose number 4 from listbox
On this code
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Dim SqlStr As String
SqlStr = "Select * from tblokkies where leidraad = """ & ListBox1.Items(ListBox1.SelectedIndex) & """"
FillTextBox(SqlStr)
End Sub
On F8
SqlStr = "Select * from tblokkies where leidraad = """ & ListBox1.Items(ListBox1.SelectedIndex) & """"
SqlStr ========"Sqltr "Select *from tblokkies where leidraad = "'n uitroep""
ListBox1.SelectedIndex)=========="Listbox1.Seletectedindex 3
FillTextBox(SqlStr) ========"Filltextbox Nothing
It then fills my textboxes with this info
4. info in this from row in my table ====Luidraad ='n uitroep" A1=gits, A2=aag,A3=SA (My textboxes luidraad,A1,A2,A3,)
Want to put info now in A4=test" (textbox A4)
4. Click on Save button.
On this code after F8
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
If SaveOrEdit = "Save" Then
Dim add As DialogResult
add = Cls_MessageBbox.Show("Is jy Seker jy will Leidraad" & vbCrLf & vbCrLf & TxtLuidraad.Text & vbCrLf & vbCrLf & "Byvoeg", "Byvoeg.", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If add = Windows.Forms.DialogResult.Yes Then
AddNew()
Else
ListBox1.Text = "Geen leidraad is Bygevoeg nie"
End If
ElseIf SaveOrEdit = "Edit" Then
Edit()
Else
StatusLabel.Text = " Geen Leidraad is bygevoeg"
End If
End Sub
If SaveOrEdit = "Save" Then =====Saveoredit ""
Then jumbs to
ElseIf SaveOrEdit = "Edit" Then =======Saveordeit ""
StatusLabel.Text = " Geen Leidraad is bygevoeg"=========Statuslabel.text "Leidradd :'n Uiroep: geselkteer"
After F8
StatusLabel.Text = " Geen Leidraad is bygevoeg"=========Statuslabel.text "Geen Leidraad is bygevoeg"
This is where it stops.
|
|
|
|
|
I understood that the btnAdd_Click handler is the save-button. Somehow it does trigger this for the first three textboxes (as you said they were saved correctly), but number four is out.
The variable SaveOrEdit hasn't got the value "Edit", which would trigger the Edit() function. The question remains why it works for the first three textboxes differently then for the fourth.
It 'feels' like there's something wrong with the program-flow, but I can't point where the pain precisely is
I are troll
|
|
|
|
|
How its possible to Connect the Vc+.NET application with webservice.
i want to Post the Values of Some fields on Submit button clicking To WebService( designed in c#.NET)
What type of project should i take either MFC or else plz guide
|
|
|
|
|
i'm wondoring which is better !!
1.openning the connection to the database and leaving it opened untill the application is closed.
2.closing that connection and openning it again when i a need to connect
,which means i will open and close the connection many times while the application is running !!
thanks in advance
|
|
|
|
|
Just a technical point: assuming that the connection is by the same program to the same file, the connection doesn't get closed and opened lots of times. Most database drivers use connection pooling, which caches the database connection. This increases the speed considerably
Personally, I would go with the second option. I don't write database programs often, but with the advent of connection pooling, the speed reduction is virtually eliminated. On the other hand, a program may terminate abnormally; an example of this would be the 'End Process' button in Task Manager. If that happens, I don't know if the connection would get terminated
This choice is just my opinion really. It may not be right, but it goes with my general method of retrieving data: get in, read it as quickly and efficiently as possible, get out, deal with the extracted data
|
|
|
|
|
thanks for ur reply ,
but i didn't get the meaning of connection pooling !
and what is the advantage?
i thought about it ,
i think if the program depends on a database which is on pc other than the application pc , it may be better if i use option 2 because of network traffic and security issues
beside if the database is on the application pc itself i would use option 1
that is my opinion and am not sure if it is better
|
|
|
|
|