|
There is no such thing as "initializing a module". Your code may require something to be setup, but a module (not your code) doesn't need anything to initialize.
|
|
|
|
|
Does a dataset retain the original value for each field after it has been changed. For example is I have a field called Name with is set to equal 'Fred' then I change it to equal 'Joe', is there away of getting the orginal value from the dataset, or do I have to store the original value else where?
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|
|
Yes, each DataRow object maintains a DataRowVersion of itsself. The orignal value is maintained so long as the DataRow (or parent table) does not have it's AcceptChanges, RejectsChanges, or any other method that refreshes the dataset, called. You can get at it something like:
Dim originalValue As Integer = Convert.ToInt32(MyDataTable.Rows(0).Item(someColumnNumber, DataRowVersion.Original))
Dim newValue As Integer = Convert.ToInt32(MyDataTable.Rows(0).Item(someColumnNumber, DataRowVersion.Current))
|
|
|
|
|
Thanks Dave, I knew I had dreamt it. Thanks again, you really are a Super Guru, aren't you!?
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|
|
Steven J Jowett wrote: you really are a Super Guru, aren't you!?
Not really, but my Google-Fu is very strong.
|
|
|
|
|
hy everyone!
i know my question is of topic but maybe someone has an idea why this problem occures:
I do have a macro which parses files. when finished i want to move the file to a different directory (either the one, where well parsed files are put into or in the one where bad parsed files are put into).
therefor i have to use the movefile and deletefile.
because my macro first checks, if there is already and (old) copy of the file, if so then delete it and replace it with the new one. if not then i simply copy it to the destination file.
therefor i programmed
Function DeleteandMoveFile(ByVal dest As String, ByVal source As String, ByVal filename As String) As Boolean
Dim filesys As Object
DeleteandMoveFile = TRUE 'just a dummy operation
Set filesys = CreateObject("Scripting.FileSystemObject")
'Check if File exists in destinationpath then delete it
If filesys.FileExists(dest & filename) Then
If filesys.DeleteFile(dest & filename)then
'MsgBox "file deleted successfully
Else
'MsgBox "couldn't delete file"
Application.WriteEventLog "macro", "couldn't delete file",5
End If
End If
' Check if file exists in source path then move it
If filesys.FileExists(source & filename) Then
If filesys.MoveFile(source & filename, dest)
'MsgBox "file moved"
Else
Application.WriteEventLog "macro", "file couldn't be moved!",5
End If
Else
Application.WriteEventLog "macro", "file does not exist!" ,5
End If
Set filesys = Nothing
End Function
Looks fine, doesn't it? Well the macro does exactly what I want it to, but it also writes the error messages into eventlog. Meaning it does the if statements but the steps directly to the error message and continues operating. As if I also added the error message to the if statement.
Does anyone of you have an idea? Does Windows somehow have a handle or something on the file which causes an exception when moving or deleting??
If it doesn't work, then it would be "ok" for me, but remember: The macro does what I want it to but throws the error messages as well (seems to be in if and else during the same loop!).
Maybe anyone of you could help me please!
thanks.
Stephan.
|
|
|
|
|
Simpler idea. First, check if the source file exists. Then, if it does, just copy the file from the source to the destination, overwriting the destination if the same filename exists. That way, you don't have to care if the destination exists, just to delete the thing anyway.
Now, on to your actual problem. Since MoveFile and DeleteFile do NOT return any kind of value, I think your actually checking the FSO object instance being Nothing, which will return False, and hence, log an error message.
To prevent weird problems like this, I usually don't call methods on objects inside conditional expressions. I usually assign return values to vairables and use those variables in the expressions instead. This allows for additional checking of return values, such as valid objects and values within expected ranges.
|
|
|
|
|
thanks for the hint!
unfortunatly i encountered another problem:
sometimes this statment seems to return "false" even if the file is located at the specified folder, any ideas?
<br />
If filesys.FileExists(source & filename) Then <br />
let's say source is "C:\myfiles\todo\"
and filename is "myfile.txt"
then the whole string is "C:\myfiles\todo\myfile.txt". (in debugmode the contence of the variables is correct (i already checked that).
i also checked, the file is at the specified path, so this statement should return true, but it doesn't and I have no idea why.
are there some circumstances, when this statement returns a wrong result?
could it be, there is a non printable sign somewhere inbetween (a string endsign for example)??
because when I debug the code then it stops at this line (breakpoint) and when I do a step forward, the whole if branch is skipped and the code continues either at the else part or (if there is none) below the whole if .. endif statment.
did anyone of you encounter the same problem? why does the exists statement return false, if the file is there??
if i am able to solve this problem, my script is finished and should be working correctly
thanks.
stephan.
|
|
|
|
|
I've never ran into the problem myself, nor have I heard of an instance when the function returned the wrong result.
But, I've already told you why I don't embed calls to methods inside an IF statements conditional expression.
|
|
|
|
|
i guess i should try to check the string in a variable if it is correct and then check the result in a variable as well.
well, strange things happen in my macro but i hope i will solve them all soon
|
|
|
|
|
I have encountered a similar problem whan the FOLDER did not exist - in my case i had a path like c\work\temp - i.e. I missed the : after the drive.
Could a \ be missing in part of your path?
Bob
Ashfield Consultants Ltd
|
|
|
|
|
hm, i guess not, but i will check it.
because if i remove the check and let the file be moved or deleted, then it uses the same source or destination path. and this command works (meaning it moves or deletes the file). so i guess the path should be correct.
|
|
|
|
|
Hello
I am testing a VB 2008 application which will allow the user to select a PDF, add a pre-defined annotation, and save the file back to disk. That's all I want from the program at the moment. However, I get a runtime error when I try to create the AcroExch.App object so that my application can interact with Acrobat. I get the "Can not create ActiveX Component" exception handler on the screen when I try to debug or launch my application. Does anyone know what this means?
I bolded the offending code below. Thanks!
Public Class Form1
Dim gApp As Acrobat.CAcroApp
<p>
Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
gApp = CreateObject("AcroExch.App")
End Sub <p>
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim pdDoc As Acrobat.CAcroPDDoc
Dim page As Acrobat.CAcroPDPage
Dim jso As Object
Dim path As String
Dim point(1) As Integer
Dim popupRect(3) As Integer
Dim pageRect As Object
Dim annot As Object
Dim props As Object
<p>
OpenFileDialog1.ShowDialog()
path = OpenFileDialog1.FileName
<p>
pdDoc = CreateObject("AcroExch.PDDoc")
<p>
If pdDoc.Open(path) Then
jso = pdDoc.GetJSObject
If Not jso Is Nothing Then
' Get size for page 0 and setup arrays
page = pdDoc.AcquirePage(0)
pageRect = page.GetSize
point(0) = 0
point(1) = pageRect.y
popupRect(0) = 0
popupRect(1) = pageRect.y - 100
popupRect(2) = 200
popupRect(3) = pageRect.y
' Create a new text annot
annot = jso.AddAnnot
props = annot.getProps
props.Type = "Text"
annot.setProps(props)
' Fill in a few fields
props = annot.getProps
props.page = 0
props.point = point
props.popupRect = popupRect
props.author = "Rob McAfee"
props.noteIcon = "Comment"
props.strokeColor = jso.Color.red
props.Contents = "I added this comment from Visual Basic!"
annot.setProps(props)
pdDoc.Close()
MsgBox("Annotation added to " & path)
Else
MsgBox("Failed to open " & path)
End If
End If
pdDoc = Nothing
End Sub
<p>
End Class</p></p></p></p></p></p>
|
|
|
|
|
Do you have either Adobe Acrobat Standard or Professional editions installed?? If not, you dead in the water.
|
|
|
|
|
Ahhh. I have only the Reader 8.0 on the machine I am testing.
Thanks.
|
|
|
|
|
Good Afternoon All
I have a working Application that has a uses a Datagrid, and there are Records that have been added recently and they have a Add_Date field Populated with the Current date, so that is the only way to Distinguish between the old records and the new one, i would like my Datagrid to Display a Different or unique Colour on the whole row only for the records that a field Add_Date not null.
How can i achieve that in vb.net
thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
|
I am using vb.net 2003 in my Project with MySQL 4.1 as backend in the .Net Framework 1.1.
Now I want use MySQLDirect .NET 5.1 as an provider in the same project with the
same requirement ( Vb.net 2003 as front end,MySQL 4.1 As Backend, .Net FrameWork 1.1 ).
Is it possible to use MySQLDirect .NET 5.1 in .NET framework 1.1 or not ?
|
|
|
|
|
We're not the people to ask this question of. You should be asking the people who wrote the MySQLDirect library, here[^]. But, on their homepage, it look like it works with all versions of the .NET Framework.
|
|
|
|
|
Dear Friends,
When loading set of data into combo box i have facing the problem .
"381 Invalid property array index"
record is above 33 thousands
here is the coding
If Not (objResultset.EOF And objResultset.BOF) Then<br />
objResultset.MoveFirst<br />
Do While Not objResultset.EOF<br />
<br />
cboPatient.AddItem objResultset("pid") & "|" & objResultset("name_first")<br />
cboPatient.ItemData(cboPatient.NewIndex) = objResultset("pid") 'problem occurs here<br />
<br />
objResultset.MoveNext<br />
Loop<br />
<br />
cboPatient.ListIndex = -1<br />
End If
any can able to help me its very urgent please
thanks in advance
give solution and samples
regards
kankeyan
|
|
|
|
|
33000 items? who is going to read or browse these??
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
THIS IS RELATED TO BILL ENTRY, SELECTION OF PATIENT NAME AND ID
|
|
|
|
|
you can't expect users to select from a huge collection in one step.
instead use two or three steps, e.g. let them choose or enter the first (or first few)
characters, show the results and let them then pick one from those results.
that is how all systems do it; even here at the CP forums, you get 25 or so at a time,
either from the entire collection (see this forum) or from a subset (when you perform
a find).
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Hi All,
I'm teaching myself as I go as we can't afford to outsource a few "simple" requirements to a real programmer. I'm running a form which has 5 rows (Monday to Friday) when the user clicks submit it checks if data has been entered on a row, if it has it looks in the db to see if there is already data and then chooses insert or update.
This works fine for the first row and then times-out on the second row while checking if there is data. The query runs fine in query analyzer.
I call the select that looks for existence of data as a function with
sqlCheckResponse = flexi_actions.CheckInsUpd(userID, txtDate2.Text)
and....
Function CheckInsUpd(ByVal userID As Integer, ByVal inputDate As String) As Integer
Try
Dim sqlCheckConn As New SqlConnection(strConn)
Dim strcheckSQL As String = "select count(detailID) from flexiDetail where userID = @uID and flexiDate = @fDate"
sqlCheckConn.Open()
Dim checkCmd1 As New SqlCommand(strcheckSQL, sqlCheckConn)
checkCmd1.Parameters.AddWithValue("@uID", userID)
checkCmd1.Parameters.AddWithValue("@fDate", inputDate)
CheckInsUpd = checkCmd1.ExecuteScalar 'timesout on this line...
sqlCheckConn.Close()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Function
Any help appreciated!
Thanks
Paul
|
|
|
|
|
First, are the dates stored in your database using DateTime types or strings?? If strings, you're in trouble...
Second, pass dates in your code AS Date objects, not strings. AddWithValue is probably the worst method you could use to add a paramter to an SQL query. It infers what the proper date type might be by looking at the type of the value your passing it. In your case, you passed the inputDate as a string to the AddWithValue parameter, which probably added the parameter to the SQL statement as an nvarchar(x) , not an SQL DateTime. This might be where your SQL is hanging up.
How long does this query take to run in Query Analyzer?
|
|
|
|
|