Need help with my code, I use SQL syntax. - Request = "INSERT INTO tblEmployeeInfo VALUES(" & Replace(Me.txtID.Text, "'", "''") & "," & _
-
"'" & AccessCode & "'," & _
-
"'" & Replace(Me.txtLastName.Text & ", " & Me.txtFirstName.Text _
-
& " " & Me.txtMidleName.Text, "'", "''") & "'," & _
-
"'" & Replace(Me.cboGender.Text, "'", "''") & "'," & _
-
"'" & Format(Me.dtpBDate.Value, "MM/dd/yyy") & "'," & _
-
"'" & CurrentAge & "'," & _
-
"'" & Replace(Me.txtAddress.Text, "'", "''") & "'," & _
-
"'" & Replace(Me.txtContact.Text, "'", "''") & "'," & _
-
"'" & Replace(Me.txtEmail.Text, "'", "''") & "'," & _
-
"'" & Replace(Me.mskFrom.Text, "'", "''") & "'," & _
-
"'" & Replace(Me.mskTo.Text, "'", "''") & "'," & _
-
"'" & Replace(Me.cboDepartment.Text, "'", "''") & "'," & _
-
"'" & Replace(Me.phProfiler.SavePhoto, "'", "''") & "')"
I use a user control for the photo and i got an Argument not Optional error in this line ""'" & Replace(Me.phProfiler. SavePhoto, "'", "''")". Please help me with this. Thanks in advance.
5 1887
what is phProfiler in your code ?
and what does SavePhoto property stores ?
From the sound of it, the SavePhoto function requires an argument. Pure speculation here, but I'd guess that it expects a string containing the name of a file in which to save the photo.
As debasisdas pointed out, we need more info as to exactly what type of object phProfiler is, and what SavePhoto is/does. The chances are good that in providing that info you'll probably come up with the answer yourself. :-)
Thank you for your quick replies sir(s). phProfiler here is a user control for displaying photo and PhotoSave is its property of inserting the selected image file within the database as an ole object. What sir killer42 said yes it expects for a string containing the file but still no luck.
What happens then, when you supply a string argument to SavePhoto? This seems to be the main problem.
The way SavePhoto is used here is a bit confusing. Does it also return a string value? If not, then you won't be able to use it in the Replace function in this way.
One thing I always recommend when debugging is to zero in and isolate the specific piece of code which is producing the problem. So for example, I'd comment out the whole Assignment statement (Request = blah blah...) and just do something like Debug.Print Me.phProfiler.SavePhoto(<your argument>). If you can't get a string out of it, then there's no point trying to use that string in the INSERT and so on.
(Note that it only requires one ' at the start of the statement to comment out the entire block, not on every line.)
Thank you again for doing a great job. I had it fixed! instead of using this user control, i just switched to using this code. - Private Sub cmdselect_Click()
-
On Error Goto Err_CS:
-
'Select an image file to open
-
With dlgSelect
-
.CancelError = True
-
.DialogTitle = "Select image..."
-
.Filter = "Image Files (*.jpg, *.bmp, *.gif)|*.jpg;*.bmp;*.gif"
-
.ShowOpen
-
txtImagePath = .FileName
-
If Trim$(txtImagePath.Text) <> "" Then
-
LoadPointerImage (Trim$(txtImagePath.Text))
-
End If
-
End With
-
-
Exit Sub
-
-
Err_CS:
-
If Err.Number <> 32755 Then 'User cancelled
-
Err.Raise Err.Number, Err.Source, Err.Description
-
Err.Clear
-
End If
-
End Sub
-
-
Sub LoadPointerImage(sImage As String)
-
-
On Error GoTo Errorhandler:
-
'Load the file pointer into the Image control
-
If Len(Dir(sImage)) Then
-
picEmployee.Picture = LoadPicture(sImage)
-
Else
-
picEmployee.Picture = LoadPicture()
-
End If
-
PicBlank.Visible = False
-
Exit Sub
-
Errorhandler:
-
Err.Raise Err.Number, Err.Source, "File does not appear to be a valid image file..." & _
-
vbCrLf & vbCrLf & Err.Description
-
Err.Clear
-
End Sub
-
-
Function VerifyAndSave() As Boolean
-
-
On Error GoTo Errorhandler:
-
Call Info
-
Dim strMsg, ans As String
-
Dim bytBLOB() As Byte
-
Dim strImageTitle As String
-
Dim strImagePath As String
-
Dim intNum As Integer
-
-
-
strImagePath = Trim$(txtImagePath.Text)
-
InfoRS.Find "EM_ID='" + txtEM_ID.Text + "'", 0, 1
-
With InfoRS
-
If (txtImagePath.Text <> "") Then
-
'Open the picture file
-
intNum = FreeFile
-
Open strImagePath For Binary As #intNum
-
ReDim bytBLOB(FileLen(strImagePath))
-
-
'Read the data and close the file
-
Get #intNum, , bytBLOB
-
Close #1
-
.Fields("PICTURE").AppendChunk bytBLOB
-
-
End If
-
.Update
-
End With
-
-
Exit Function
-
Errorhandler:
-
MsgBox "Error :" & " " & Err.Number & Err.Description, vbCritical
-
Err.Clear
-
-
End Function
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Tim Thomas |
last post by:
Hi,
I am very new to .NET and am in the process of building my first web
application.
I will briefly describe what i am trying to achieve:
I have a system where suppliers register their...
|
by: 42 |
last post by:
Hi,
I've run into a block, that I'm almost sure is really simple...but I
can't seem to clue in right now.
I'd like to create a user control that takes input like this:
<mycontrol:panel...
|
by: martin |
last post by:
Hi,
I am a web page and a web user control. My web user control is placed in my
web page using the following directive
<%@ Register TagPrefix="uc1" TagName="Header"...
|
by: Shourie |
last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle.
1) MainPage_load
2) User control1_Load
user clicks a...
|
by: louise raisbeck |
last post by:
Resending this as own topic as didnt get answer from original. Would be
grateful for a response from anyone that knows. Thanks.
Hi there, I found your post really helpful..but i wondered if, once...
|
by: EvelynAnd Ethan |
last post by:
Hi,
ItemCommand event not firing from a dynamic user control ,WHERE A
DATAGRID HAS BUTTON,when i click on the linkbutton first time the
itemcommand event doesnt fire,second time event fires up
...
|
by: tony |
last post by:
Hello!
This is a rather long mail but it's a very interesting one.
I hope you read it. I have tried several times to get an answer to this mail
but I have
not get any answer saying something...
|
by: fernandezr |
last post by:
I would like to use a user control as a template inside a repeater.
Some of the fields in the control should be hidden depending on whether
or not there is data. I'm still a ASP .Net newbie so the...
|
by: rn5a |
last post by:
Assume that a user control (MyUC.ascx) encapsulates 2 TextBoxes with
the IDs 'txt1' & 'txt2' respectively. To use this user control in an
ASPX page, the following Register directive will be...
|
by: |
last post by:
I have what's probably a simple page lifecycle question related to
dynamically evaluating values that are placed by a repeater and dynmically
placing user controls that use those values.
I'm...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |