473,414 Members | 1,667 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

User Control Photo

Richard Alvarez
Need help with my code, I use SQL syntax.
Expand|Select|Wrap|Line Numbers
  1. Request = "INSERT INTO tblEmployeeInfo VALUES(" & Replace(Me.txtID.Text, "'", "''") & "," & _
  2.      "'" & AccessCode & "'," & _
  3.      "'" & Replace(Me.txtLastName.Text & ", " & Me.txtFirstName.Text _
  4.                             & " " & Me.txtMidleName.Text, "'", "''") & "'," & _
  5.                 "'" & Replace(Me.cboGender.Text, "'", "''") & "'," & _
  6.      "'" & Format(Me.dtpBDate.Value, "MM/dd/yyy") & "'," & _
  7.      "'" & CurrentAge & "'," & _
  8.      "'" & Replace(Me.txtAddress.Text, "'", "''") & "'," & _
  9.      "'" & Replace(Me.txtContact.Text, "'", "''") & "'," & _
  10.      "'" & Replace(Me.txtEmail.Text, "'", "''") & "'," & _
  11.      "'" & Replace(Me.mskFrom.Text, "'", "''") & "'," & _
  12.      "'" & Replace(Me.mskTo.Text, "'", "''") & "'," & _
  13.      "'" & Replace(Me.cboDepartment.Text, "'", "''") & "'," & _
  14.      "'" & 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.
Jun 15 '11 #1
5 1887
debasisdas
8,127 Expert 4TB
what is phProfiler in your code ?

and what does SavePhoto property stores ?
Jun 15 '11 #2
Killer42
8,435 Expert 8TB
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. :-)
Jun 16 '11 #3
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.
Jun 17 '11 #4
Killer42
8,435 Expert 8TB
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.)
Jun 21 '11 #5
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.
Expand|Select|Wrap|Line Numbers
  1.  Private Sub cmdselect_Click()
  2. On Error Goto Err_CS:
  3.     'Select an image file to open
  4.     With dlgSelect
  5.         .CancelError = True
  6.         .DialogTitle = "Select image..."
  7.         .Filter = "Image Files (*.jpg, *.bmp, *.gif)|*.jpg;*.bmp;*.gif"
  8.         .ShowOpen
  9.         txtImagePath = .FileName
  10.         If Trim$(txtImagePath.Text) <> "" Then
  11.             LoadPointerImage (Trim$(txtImagePath.Text))
  12.         End If
  13.     End With
  14.  
  15.     Exit Sub
  16.  
  17. Err_CS:
  18.     If Err.Number <> 32755 Then 'User cancelled
  19.         Err.Raise Err.Number, Err.Source, Err.Description
  20.         Err.Clear
  21.     End If
  22. End Sub 
  23.  
  24. Sub LoadPointerImage(sImage As String)
  25.  
  26.     On Error GoTo Errorhandler:
  27.     'Load the file pointer into the Image control
  28.     If Len(Dir(sImage)) Then
  29.         picEmployee.Picture = LoadPicture(sImage)
  30.     Else
  31.         picEmployee.Picture = LoadPicture()
  32.     End If
  33.     PicBlank.Visible = False
  34.     Exit Sub
  35. Errorhandler:
  36.     Err.Raise Err.Number, Err.Source, "File does not appear to be a valid image file..." & _
  37.         vbCrLf & vbCrLf & Err.Description
  38.     Err.Clear
  39. End Sub
  40.  
  41. Function VerifyAndSave() As Boolean
  42.  
  43.     On Error GoTo Errorhandler:
  44.     Call Info
  45.     Dim strMsg, ans As String
  46.     Dim bytBLOB() As Byte
  47.     Dim strImageTitle As String
  48.     Dim strImagePath As String
  49.     Dim intNum As Integer
  50.  
  51.  
  52.     strImagePath = Trim$(txtImagePath.Text)
  53.     InfoRS.Find "EM_ID='" + txtEM_ID.Text + "'", 0, 1
  54.         With InfoRS
  55.             If (txtImagePath.Text <> "") Then
  56.                 'Open the picture file
  57.                 intNum = FreeFile
  58.                 Open strImagePath For Binary As #intNum
  59.                 ReDim bytBLOB(FileLen(strImagePath))
  60.  
  61.                 'Read the data and close the file
  62.                 Get #intNum, , bytBLOB
  63.                 Close #1
  64.                 .Fields("PICTURE").AppendChunk bytBLOB
  65.  
  66.            End If
  67.         .Update
  68.         End With
  69.  
  70.     Exit Function
  71. Errorhandler:
  72.        MsgBox "Error :" & " " & Err.Number & Err.Description, vbCritical
  73.        Err.Clear
  74.  
  75. End Function
Jun 24 '11 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
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...
3
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...
6
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"...
1
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...
4
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...
4
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 ...
0
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...
8
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...
2
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...
7
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...
0
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
0
BarryA
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...
0
marktang
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,...
0
Oralloy
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,...
0
jinu1996
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...
0
tracyyun
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...
0
agi2029
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,...
0
isladogs
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...
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.