|
Please Check your data type against your Variable data.
and why you use Paramenters. It is meaning less.
Anubhava
|
|
|
|
|
idsanjeevjha wrote: 'This code is not working reports error
What is the error ? You have use @ symbol for parameter. I believe you should use ? symbol for parameters in Odbc.
|
|
|
|
|
i am getting ERROR [42000] [Microsoft][ODBC driver for Oracle][Oracle]ORA-00936: missing expression.
ya i have to use ? symbol for parameter in odbce but why @ is used in sql or msaccess
thanks
sanjeev
|
|
|
|
|
That depends on the databases. SQL and access uses @ symbol.
|
|
|
|
|
It may not help much, but when using an old version of sqlce, I used to use the following to add a parameter to the query:
cmd.Parameters.Add(New SqlCeParameter("id", SqlDbType.Int)).Value = nextID
maybe you can modify to get it working?
|
|
|
|
|
Code for data insertion is not work reported error
<script runat="server">
Sub submit(sender As Object, e As EventArgs)
dim dbconn,sql,dbcomm,dbread
dbconn=New ODbcConnection("dsn=oracle;uid=starter;pwd=starter;")
dbconn.Open()
sql="SELECT * FROM students"
dbcomm=New ODbcCommand(sql,dbconn)
dbread=dbcomm.ExecuteReader()
customers.DataSource=dbread
customers.DataBind()
dbread.Close()
dim isql,idbread,idbcomm
isql="Insert Into students(id,first_name,last_name,major) values (@fname,@id,@lname,@major)"
idbcomm=new odbccommand(isql,dbconn)
idbcomm.Parameters.Add( "@fname",fname.text)
idbcomm.Parameters.Add( "@id",id.Text)
idbcomm.Parameters.Add( "@lname",lname.Text)
idbcomm.Parameters.Add( "@major",major.Text)
idbcomm.ExecuteNonQuery()
dbconn.Close()
End Sub
</script>
but this code is excuted success fully
<script runat="server">
Sub submit(sender As Object, e As EventArgs)
Dim strConnectionString As String
strConnectionString = "Dsn=oracle;uid=gatepass;pwd=gp"
Dim pConn As New OdbcConnection(strConnectionString)
'Dim pSELECTQUERY As String = "SELECT *from students"
Dim pSELECTQUERY As String = "SELECT distinct PassMaster.*,passarea_dtls.passarea,empmaster.empname,visitormaster.visitorname FROM PassMaster, VisitorMaster,passarea_dtls,empmaster where passmaster.authorisationby=empmaster.empno and passmaster.passareacode=passarea_dtls.passareacode and PassMaster.PassIssueDt + PassMaster.validity -1 >= trunc(sysdate) and PassMaster.PassID = VisitorMaster.PassID and PassMaster.AuthorisationStatus = 'YES' and passmaster.PASSISSUESTATUS not like 'YES' order by PassMaster.PassID"
Dim adapter As New OdbcDataAdapter(pSELECTQUERY, pConn)
Dim DS As DataSet = New DataSet()
adapter.Fill(DS)
Repeater1.DataSource = ds
pConn.Close()
adapter.Dispose()
Repeater1.DataBind()
End Sub
</script>
i don't know whats is the reason any help ?
sanjeev
|
|
|
|
|
try changing
isql="Insert Into students(id,first_name,last_name,major) values (@fname,@id,@lname,@major)"
to
isql="Insert Into students(id,first_name,last_name,major) values (@id,@fname,@lname,@major)"
|
|
|
|
|
Thanks for your reply
Please see my last post where i already changed some code problems in commented code is not worked but other code thats is not commented is inserted data successfully.
so i wants to know whats is the mistakes in my commented code
thanks
sanjeev
|
|
|
|
|
Yep. I spotted that after I had posted the Q.
|
|
|
|
|
I used AxShockwaveFlash Object to play first.swf file, i wanna play second.swf when first.swf complete so how can i get the total completion time period of flash file, means each swf file must play only once then load next swf file..
Can anyone give me suggestion 4 this
Thanks with annticaptions
Unless u don't give ur hundred percent whatever u r doning till there is no result of ur work...
|
|
|
|
|
I have some code that reads email items and their attachments and then moves the mail item to a "Processed" folder in the users mail box. In general it works ok, but if the attachment in a file type that is not recognised (this raises an error), I want to identify the mail item and move it to a different folder. When I debug my code, the appropriate catch statements seem to get called and the flags set correctly, but when I get the part of the code that moves the mail items, the one that raised the error gets moved into the "Processed" folder and not the "Failed" folder.
Can anyone see what I am doing wrong?
In the code below, theMailItem is a structure.
I.E.
<br />
Public Structure TheMailItem<br />
Dim theItem As MailItem<br />
Dim theMove As Boolean<br />
Dim theFail As Boolean<br />
End Structure<br />
For Each theMailItem In theMailItems
Try
ReadMailItem(theMailItem.theItem)
Catch ex As InvalidCastException
theMailItem.theFail = True
theMailItem.theMove = False
Catch ex As NullReferenceException
theMailItem.theFail = True
theMailItem.theMove = False
Catch ex As System.Exception
theMailItem.theFail = True
theMailItem.theMove = False
End Try
Next
For Each theMailItem In theMailItems
'Move any processed items
If theMailItem.theMove = True Then
theMailItem.theItem.Move(theMoveFolder)
End If
'Move any fail items
If theMailItem.theFail = True Then
theMailItem.theItem.Move(theFailedFolder)
End If
Next
|
|
|
|
|
I love it "programming by error", perfect example, try something and when it fails try something else, when the error trap fails (possibly becasue the variable is now out of scope) ask on CP.
Where do these ideas come from, you KNOW there may be errors, you know where they are, you know what causes them, for all thats sensible TEST the attachment BEFORE you attempt to move it, don't rely on your error handling to do your job for you.
Sorry for the rant....
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I would love to test the attachment before attempting to read it (I want to move the whole email-not the attachment). I just can't find any information about how to test it. If you know of any good Outlook API programming resources I would be grateful. I can't find any and MSDN is just about worthless.
Testing first (which I agree would be the best thing) is not really the question. The question is why do the flags seem to be set in the catch statements but revert to the default settings.
The variable is not out of scope (I think). The catch block seems to set the flags ok and when I step through it the email item is still set.
(I have stripped out some of the other parts of the catch statements and also want to develop this up so that it moves files that throw different exceptions to different folders - I just wanted to keep my question as simple as possible).
Also, I don't mind the rant. I realise that I am opening up for criticism of my code when I post here. I don't do it without looking everywhere I can for an answer first.
|
|
|
|
|
RCoate wrote: opening up for criticism of my code when I post here
I don't have an issue with your code - seems Ok to me, I just hate the use of the exception handler as any thing but a disaster trap.
RCoate wrote: I would love to test the attachment before attempting to read it
I'm pretty sure you can save the attachment via the API. This would then let you inspect the attributes of the file. I know this is a kludge but may be an option.
I also seem to remember there was an array of attachments within the mail object that can probably be inspected directly.
RCoate wrote: good Outlook API programming resources
Sorry - I hate Outlook as much as the next bloke so my knowledge is limited.
I realise you want to move the whole message but you have identified the problem that is stopping you so now you need to handle the attachment issue before attempting to move the mail object.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: I love it "programming by error"
Yes, very lovely
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
The problem you are having is caused by the way structures are handled. When you declare a class, you essentially pass around a pointer and code like
Dim A as new SomeObject
A.SomeProperty = 3
Dim B As SomeObject = A
B.SomeProperty = 5
Console.WriteLine(A.SomeProperty)
would output 5. However with structures, you are actually making copies of the data. So for your code, the first loop makes a copy of the items in the array, then modifies the properties of the *copies* in the exception handlers. You have two options. One is to change TheMailItem to a class, which is probably a better option if MailItem (the type of one of the properties on TheMailItem) is a class. The other is to combine the loops into a single loop. Here's some code to show that structures really are copied:
Sub Main()
Dim items(10 - 1) As CopyTest
Dim i As Integer
Dim ct As CopyTest
For i = 0 To items.Length - 1
items(i) = New CopyTest
items(i).Original = i
items(i).Modified = i
Next
Console.WriteLine("Original Values:")
For Each ct In items
Console.WriteLine("Original: {0} Modified: {1}", _
ct.Original, ct.Modified)
Next
Console.WriteLine("Modifications in progress:")
For Each ct In items
ct.Modified = ct.Modified * 3
Console.WriteLine("Original: {0} Modified: {1}", _
ct.Original, ct.Modified)
Next
Console.WriteLine("After Modifications:")
For Each ct In items
Console.WriteLine("Original: {0} Modified: {1}", _
ct.Original, ct.Modified)
Next
Console.ReadKey()
End Sub
Private Structure CopyTest
Public Original As Integer
Public Modified As Integer
End Structure
|
|
|
|
|
Thanks Gideon.
That makes sense.
I changed the structure to a class and it is working now.
modified on Thursday, July 3, 2008 12:25 AM
|
|
|
|
|
I'm stumped on something that should be simple, but.....
I've written a VBscript to create a folder on an IOMega NAS box using objFSO.CreateFolder, and copy some files to it for backup. It runs on a server using Win2003R2. The NAS box is mapped to a local drive letter on this server.
I use cscript to run the script, fired off by the scheduler at night, under an Administrator user ID.
The script works fine in debug mode.
If I execute the script from a Run|cmd command line, it works fine.
When kicked off by the scheduler, it always fails on the CreateFolder method with a 76 error (path not found).
But if I open the scheduler, right click on the job and select "Run", it runs the job with no problems and completes successfully!
I've inserted some debug code before the CreateFolder, checking for FolderExists on the NAS box and that is always successful. The first hint of trouble is the 76 error on the CreateFolder method.
Here's some of the code. "x" is the mapped drive.
BTW: all of the code referencing "NAS disks to spinup" was added to get around this 76-error problem, under the assumption that idled disks were the culprit; none of it helped.
Const Backupfolder = "x:\Data Backups"
.
.
.
' Checking to see if NAS disks are still spinning
If objFSO.FolderExists(Backupfolder) Then i=1
writelog ("check that NAS disks are spinning: err.num: " & Err.Number & " " & Err.Description)
errHandler ("checking if NAS disks are spinning")
' Generate today's directory name in the format yymmdd
strmonth = month(date)
if strmonth < 10 then strmonth = "0" & strmonth
strday = day(date)
if strday < 10 then strday = "0" & strday
todaysfolder = right(year(date),2) & strmonth & strday
' Now create the full pathname to today's backup folder
todayspath = Backupfolder & "\" & todaysfolder
' Create todays backup folder
If objFSO.FolderExists(todayspath) Then
Set objbkupFolder = objFSO.GetFolder(todayspath)
writelog(todayspath & " already exists!")
Else
writelog("Creating folder " & todayspath)
Err.Clear
Set objbkupFolder = objFSO.CreateFolder(todayspath)
If Err.Number <> 0 Then
writelog ("Waiting 15 seconds for NAS disks to start. Err: " & Err.Number & " " & Err.Description)
Err.Clear
objbkupFolder = nothing
Wscript.Sleep 15000 'Wait 15 seconds for NAS disks to spin up
Set objbkupFolder = objFSO.CreateFolder(todayspath)
If Err.Number <> 0 Then
errHandler (" trying to create folder " & todayspath)
abendscript
End If
End If
End If
Anybody have any ideas on this?
Jeff
|
|
|
|
|
It doesn't work because the drive mapping doesn't exist under the scheduler's user session. You have to provide code in the script for mapping the drive, or just skip the drive mapping and recode the script to use UNC paths instead.
|
|
|
|
|
Changed to UNC addressing. Works like a champ now. Thanks
|
|
|
|
|
when working wit winservice will it be better to use timer or thread
|
|
|
|
|
The two are completely different concepts that do not apply to the same thing. What are you trying to do??
|
|
|
|
|
i am trying to manipulate database. insert, update and select using winservice programme
|
|
|
|
|
Hi,
if it has to work in the background and is not related to time, just use one or more extra threads.
if it is time related (e.g. a periodic action), use a timer.
|
|
|
|
|