|
I already told you what you have to do. Stop using the string concantentation method and start using the ADODB.Parameter objects to build a parameterized query that will handle all of your problems for you, automatically. You already have an example of it and if you need another one, check out Command Object Parameters[^].
If you don't do this, you're wasting your time...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
ok man i understand, but i want to know u that i program on asp.net i never used vb6.0 b4, but i use it know cause manager of me asked me to do it on vb6.0 ok, i wanna ask u how i can move the control bocx to the left cause am programming an arabic project, pls be patient with me ok man
Thanks alot
Metal Man
|
|
|
|
|
I can't find any instance of it ever being done in VB6. It can be done in VB.NET because the way Windows Forms works is very different than in VB6.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hi, ok could u tell me how i can change a field type of a database tablde in vb6.0 progrma, and if i change it every time i lood the program to the same type will it destroyed,
and i want to know what is the best field type for storing txt file in sql db
Thanks alot
Metal Man
|
|
|
|
|
Mohammad Bassam Daba`an wrote:
ok could u tell me how i can change a field type of a database tablde in vb6.0 progrma
No, I can't. I've never had cause to do this. Normally, you would never do this in your application, unless your application is a database management system. If you change the type of the column, you will most likely destroy the data in that column.
Mohammad Bassam Daba`an wrote:
if i change it every time i lood the program to the same type will it destroyed
?????????????? I take it your asking if you make the change to the database, will that change persist between sessions of your application. YES! Any change you make to the database is permanent and will not be undone when your application quits.
Mohammad Bassam Daba`an wrote:
i want to know what is the best field type for storing txt file in sql db
If you have text files of varying length and unknown content, then the best field type to use is ntext .
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Overall goal:
Allow web visitors to select frames from a streamed WMV video, then receive the selected frames via email in JPG format. No controls or specific software can be installed on or required of the client computer other than Windows Media Player 9 and IE 6.
Currently Selected Approach:
Server is IIS 5.0.
Using client-side scripting, store the user's selected frames using the Windows Media Player object's timestamp from the player.controls.currentPosition property. Then send these timestamps to an ASP "processing page" to pull the frames from the video and email them to the user. A few 3rd party controls (Server-Side ActiveX) have been found which provide the functionality to pull frames from a WMV and save them as JPEGs.
Obstacle:
None of the 3rd party controls provide an interface (COM) which is accessible to an ASP page.
Proposed Solution:
Create a COM wrapper to provide the necessary interface.
Obstacle for Proposed Solution:
Testing has shown that a VB.NET Class Library cannot be called from an ASP page unless it is registered in the Global Application Cache(GAC) using gacutil /i , which requires the Class Library to be strong-named.
The VB.NET compiler will not compile a strong-named Class Library with a reference that is not strong-named. None of the 3rd party Server-Side Controls I've found are strong-named.
-----
I need to know how to make the compiler create a strong-named Library with a reference that is not strong-named, or how to get my ASP page to create an object (Server.Createobject(progID) ) from a Library that is only listed in the Registry (regasm /u ) and NOT in the GAC.
I have tried creating a wrapper Library (not strong-named) and registering it with regasm /u , and then creating it in an ASP page Server.Createobject(progID) , but the ASP Parser gives me an error: 0x80070002 with no description.
This is the same error # as when trying to CreateObject with an invalid progID, however, in that case (invalid ID), there is a description stating that you have tried to use an invalid ID.
What I wouldn't give for a VB6 compiler. . .
I hope the information I gave isn't TOO detailed, but I know details make things easier for people to respond.
I am running out of ideas. If anyone has run into a similar problem or knows what I am doing wrong (or not doing), please help.
Alternatively, if anyone has another idea for a solution to the overall problem (way up there at the top of the post), that, too, would be greatly useful.
Many thanks in advance,
Mike the Red
|
|
|
|
|
For the 3rd party controls, you can manually create strong-named interop assemblies. You do this by using aximp (for ocx controls) or tlbimp (for dlls) with the /keyfile parameter.
my blog
|
|
|
|
|
Thank you, Mr. Campbell, it compiles like a charm, now.
I ran into another problem, though, and was hoping you or someone else might give me a hand with it.
The ASP Parser is giving me an error
Error Type:
[ProjectNamespace] (0x80070005)
Access is denied.
/test.asp, line 7
I added explicit Read & Execute access for IUSR_computerName to my wrapper DLL, the strong-named copy of the 3rd party DLL used by my wrapper, and to the MSVBVM60.DLL. This resulted in no change in the error message, however.
I also re-compiled one of my test Class Libraries (which makes no reference to other DLLs) and am able to access its namespace without error. This leads me to believe it has something to do with the wrapper's access to the 3rd party DLL, but I'm not sure.
Thanks in advance for any responses,
Mike the Red
|
|
|
|
|
Hi, working on some VB6 code and have a question about API calls.
How do I find the proper formating for the "Declare Function" statements that is needed for dll calls in VB. I have used the API Viewer for some functions, variables and constants but for other there is no info in the database file.
One example, the function SetupDiGetClassDevs in setupapi.dll is documented in msdn as
HDEVINFO SetupDiGetClassDevs(
const GUID* ClassGuid,
PCTSTR Enumerator,
HWND hwndParent, DWORD Flags);
but to use this is vb I need to first define the types used and the the actual function, would be something like, if I understand it correct:
Private Declare Function SetupDiGetClassDevs Lib "setupapi.dll" Alias "SetupDiGetClassDevsA" _
(ByRef ClassGuid As GUID, ByRef Enumerator As Long, ByRef hwndParent As Long, ByVal Flags) As Long
Then for the Flags parameter ther is several constants define DIGCF_ALLCLASSES, DIGCF_DEVICEINTERFACE, DIGCF_PRESENT, DIGCF_PROFILE and for those I cant find the actual values that I need for redefining them in VB.
The same goes for a lot of other API calls that I would like to use. Is there any update datafile for the API Viewer to dovnload or any other sorce of info on how to do, or is it all up to digg into the include files and stuff to track down the info?
regards Me
|
|
|
|
|
here:
http://www.mentalis.org/
|
|
|
|
|
I am having problem in assigning rights to a windows user.Acctually my program abnormally terminates when it executes the API function " LookupAccountName " .So if any one can show me an example to use this function and what could be the cause?
Prepare yourseld for the life after death.God bless you.
|
|
|
|
|
Has anybody tried implementing GLOBAL cbt hooks in .net?
I keep getting a .net framework runtime error as soon as the hook is activated...however it works fine LOCALY...
I just keep getting the command prompt screen with a "Runtime" error message i hate it!
|
|
|
|
|
if somthing else has it hooked already it will error out if you have it set to global.
what hook are you trying to use?
|
|
|
|
|
I'm trying to set a CBT global hook...how can I check if something else is has already set a CBT hook?
Are you sure this is why I keep getting errors?
I tried the same code and only changed the hook constant from WH_CBT to WH_KEYBOARD_LL or WH_MOUSE_LL and it works fine on the global system.
However, I keep getting the error with the WH_CBT ...
|
|
|
|
|
WH_CBT Hook
The system calls a WH_CBT hook procedure before activating, creating, destroying, minimizing, maximizing, moving, or sizing a window; before completing a system command; BEFORE removing a mouse or keyboard event from the system message queue; before setting the input focus; or before synchronizing with the system message queue. The value the hook procedure returns determines whether the system allows or prevents one of these operations.
Return Value
The value returned by the hook procedure determines whether the system allows or prevents one of these operations. For operations corresponding to the following CBT hook codes, the return value must be 0 to allow the operation, or 1 to prevent it:
HCBT_ACTIVATE
HCBT_CREATEWND
HCBT_DESTROYWND
HCBT_MINMAX
HCBT_MOVESIZE
HCBT_SETFOCUS
HCBT_SYSCOMMAND
For operations corresponding to the following CBT hook codes, the return value is ignored:
HCBT_CLICKSKIPPED
HCBT_KEYSKIPPED
HCBT_QS
Remarks
The hook procedure should NOT install a WH_JOURNALPLAYBACK_hook hook procedure except in the situations described in the preceding list of hook codes.
|
|
|
|
|
Pardon the big post...
I am using the code below to set my printer into Duplex mode, which has to be done via the driver as I sometimes want duplex printing in word, and sometimes I dont. Anyway, regardless of whether you think this can be done with System.Drawing.Printing or not, I want to limit this purely to "why do my API calls not work" as a worthwhile excercise in unmanaged code and interop...
Based on many articles I have seen on the web I came up with the class below, but it seems I am also suffering the same woes that every user who ever tried to switch duplex printing on, has suffered, and that it is hard to get it to work.
Why am I getting access denied as commented below?
Why do the docs say that OpenPrinter has to take a PRINTER_DEFAULTS byref, and when I pass it by ref, every thing breaks at runt time, like, I don't get a printer handle and OpenPrinter causes an Err.LastDllError of 5 (access denied).
I think you either know the answer to this one or not. I don't want speculcation and supposition, just hard tested solutions, coz the web is littered with suggestions that dont seem to work.
The fundamental problem seems to be that my code doesn't have the right security descriptior to use SetPrinter, even if I log on to my Windows 2003 server as an administrator.
Thanks guys, in advance for your patience and efforts!
''' TEST CODE FOR CLASS - put this in a form or module
Private Sub Test()
Dim lPrinter As New APIPrinter
Dim lName As String = lPrinter.DefaultPrinterName
lPrinter.Open(lName)
lPrinter.DuplexMode = APIPrinter.DuplexOption.LongEdge
lPrinter.Close()
End Sub
''' CODE FOR CLASS - put this in a spearate class VB file
Imports System.Runtime.InteropServices
Imports System.Text
Public Class APIPrinter
Implements IDisposable
#Region "WinApi"
#Region "Structures"
<StructLayout(LayoutKind.Sequential)> Public Structure PRINTER_DEFAULTS
<MarshalAs(UnmanagedType.LPStr)> Public pDatatype As String
Public pDevMode As IntPtr
Public DesiredAccess As Int32
End Structure
<StructLayout(LayoutKind.Sequential)> Public Structure PRINTER_INFO_2
<MarshalAs(UnmanagedType.LPStr)> Public pServerName As String
<MarshalAs(UnmanagedType.LPStr)> Public pPrinterName As String
<MarshalAs(UnmanagedType.LPStr)> Public pShareName As String
<MarshalAs(UnmanagedType.LPStr)> Public pPortName As String
<MarshalAs(UnmanagedType.LPStr)> Public pDriverName As String
<MarshalAs(UnmanagedType.LPStr)> Public pComment As String
<MarshalAs(UnmanagedType.LPStr)> Public pLocation As String
Public pDevMode As IntPtr
<MarshalAs(UnmanagedType.LPStr)> Public pSepFile As String
<MarshalAs(UnmanagedType.LPStr)> Public pPrintProcessor As String
<MarshalAs(UnmanagedType.LPStr)> Public pDatatype As String
<MarshalAs(UnmanagedType.LPStr)> Public pParameters As String
Public pSecurityDescriptor As Int32
Public Attributes As Int32
Public Priority As Int32
Public DefaultPriority As Int32
Public StartTime As Int32
Public UntilTime As Int32
Public Status As Int32
Public cJobs As Int32
Public AveragePPM As Int32
End Structure
<StructLayout(LayoutKind.Sequential)> Public Structure DEVMODE
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> Public dmDeviceName As String
Public dmSpecVersion As Int32
Public dmDriverVersion As Int32
Public dmSize As Int32
Public dmDriverExtra As Int32
Public dmFields As Int32
Public dmOrientation As Int32
Public dmPaperSize As Int32
Public dmPaperLength As Int32
Public dmPaperWidth As Int32
Public dmScale As Int32
Public dmCopies As Int32
Public dmDefaultSource As Int32
Public dmPrintQuality As Int32
Public dmColor As Int32
Public dmDuplex As Int32
Public dmYResolution As Int32
Public dmTTOption As Int32
Public dmCollate As Int32
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> Public dmFormName As String
Public dmUnusedPadding As Int32
Public dmBitsPerPel As Int32
Public dmPelsWidth As Int32
Public dmPelsHeight As Int32
Public dmDisplayFlags As Int32
Public dmDisplayFrequency As Int32
End Structure
#End Region
#Region "Constants"
Public Const DM_DUPLEX = &H1000&
Public Const DM_IN_BUFFER = DM_MODIFY
Public Const DM_MODIFY = 8
Public Const DM_PROMPT = 4
Public Const DM_OUT_BUFFER = DM_COPY
Public Const DM_COPY = 2
Public Const PRINTER_ACCESS_ADMINISTER = &H4
Public Const PRINTER_ACCESS_USE = &H8
Public Const STANDARD_RIGHTS_REQUIRED = &HF0000
Public Const PRINTER_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or PRINTER_ACCESS_ADMINISTER Or PRINTER_ACCESS_USE)
#End Region
' HELP!!!
' This is the way the docs indicate that OpenPrinter should be declared. but if I do it this way
' then the call fails as described in the code below.
'Private Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" (ByVal pPrinterName As String, ByRef phPrinter As Int32, ByRef pDefault As PRINTER_DEFAULTS) As Int32
' HELP!!!
Private Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" (ByVal pPrinterName As String, ByRef phPrinter As Int32, ByVal pDefault As PRINTER_DEFAULTS) As Int32
Private Declare Function ClosePrinter Lib "winspool.drv" (ByVal hPrinter As Int32) As Int32
Private Declare Function PrinterProperties Lib "winspool.drv" (ByVal hWND As Int32, ByVal hPrinter As Int32) As Int32
Private Declare Function DocumentProperties Lib "winspool.drv" Alias "DocumentPropertiesA" (ByVal hwnd As Int32, ByVal hPrinter As Int32, ByVal pDeviceNameg As String, ByVal pDevModeOutput As IntPtr, ByRef pDevModeInput As IntPtr, ByVal ByValfMode As Int32) As Int32
Private Declare Function GetPrinter Lib "winspool.drv" Alias "GetPrinterA" (ByVal hPrinter As Int32, ByVal Level As Int32, ByVal pPrinter As IntPtr, ByVal cbBuf As Int32, ByRef pcbNeeded As Int32) As Int32
Private Declare Function SetPrinter Lib "winspool.drv" Alias "SetPrinterA" (ByVal hPrinter As Int32, ByVal Level As Int32, ByVal pPrinter As IntPtr, ByVal Command As Int32) As Int32
Private Declare Function GetDefaultPrinter Lib "winspool.drv" Alias "GetDefaultPrinterA" (ByVal lName As String, ByRef lBuffLen As Int32) As Int32
#End Region
#Region "Properties and Enumerations"
Public Enum DuplexOption
None
LongEdge
ShortEdge
End Enum
Private mPrinterHandle As Int32
Private mDeviceMode As New DEVMODE
Private mName As String
Private mDuplexOption As DuplexOption
Private mDevModeSize As Int32
Private mMemBuffer As IntPtr
Public Shared ReadOnly Property DefaultPrinterName() As String
Get
Dim lName As String = Space(1024)
Dim lBuffLen As Int32 = Len(lName)
GetDefaultPrinter(lName, lBuffLen)
Return lName
End Get
End Property
Public Property Name() As String
Get
Return mName
End Get
Set(ByVal Value As String)
mName = Value
End Set
End Property
Public Property DuplexMode() As DuplexOption
Get
GetProperties()
Select Case mDeviceMode.dmDuplex
Case 1
Return DuplexOption.ShortEdge
Case 2
Return DuplexOption.LongEdge
Case Else
Return DuplexOption.None
End Select
End Get
Set(ByVal Value As DuplexOption)
mDuplexOption = Value
mDeviceMode.dmFields = DM_DUPLEX
Select Case mDuplexOption
Case DuplexOption.LongEdge
mDeviceMode.dmDuplex = 2
Case DuplexOption.ShortEdge
mDeviceMode.dmDuplex = 3
Case Else
mDeviceMode.dmDuplex = 1
End Select
SetProperties()
End Set
End Property
#End Region
Public Sub Open(ByVal pPrinterName As String)
Dim lDefaults As PRINTER_DEFAULTS
lDefaults.DesiredAccess = PRINTER_ALL_ACCESS
lDefaults.pDatatype = vbNullString
lDefaults.pDevMode = IntPtr.Zero
' HELP!!!
' If OpenPrinter uses ... ByRef pDefault As PRINTER_DEFAULTS then
' why does this call fail with Err.LastDllError = 5 (access denied)
' HELP!!!
Dim lRetCode As Integer = OpenPrinter(pPrinterName, mPrinterHandle, lDefaults)
If lRetCode = 0 Then
lRetCode = Err.LastDllError
End If
If Err.LastDllError = 5 Then
mPrinterHandle = 0
Else
If mPrinterHandle <> 0 Then
mDevModeSize = DocumentProperties(0, mPrinterHandle, pPrinterName, IntPtr.Zero, IntPtr.Zero, 0)
If mDevModeSize > 0 Then
mMemBuffer = Marshal.AllocCoTaskMem(mDevModeSize)
GetProperties()
Name = pPrinterName
End If
End If
End If
End Sub
Public Sub Close()
If mPrinterHandle > 0 Then
ClosePrinter(mPrinterHandle)
Marshal.FreeCoTaskMem(mMemBuffer)
End If
mPrinterHandle = 0
End Sub
Private Sub GetProperties()
If mPrinterHandle > 0 Then
Dim lRetCode As Integer = DocumentProperties(0, mPrinterHandle, mName, mMemBuffer, IntPtr.Zero, DM_OUT_BUFFER)
If lRetCode > 0 Then
mDeviceMode = Marshal.PtrToStructure(mMemBuffer, mDeviceMode.GetType)
End If
End If
End Sub
Public Sub SetProperties()
If mPrinterHandle > 0 Then
Dim lRetCode As Integer
mDeviceMode.dmOrientation = 2
mDeviceMode.dmDuplex = 2
Marshal.StructureToPtr(mDeviceMode, mMemBuffer, True)
lRetCode = DocumentProperties(0, mPrinterHandle, mName, mMemBuffer, mMemBuffer, DM_IN_BUFFER Or DM_OUT_BUFFER)
Dim lSharedStat As Boolean = SetSharedSettings()
lRetCode = DocumentProperties(0, mPrinterHandle, mName, mMemBuffer, mMemBuffer, DM_IN_BUFFER Or DM_OUT_BUFFER Or DM_PROMPT)
End If
End Sub
Private Function SetSharedSettings() As Boolean
Dim lBuffLen As Int32
Dim lRetCode As Int32 = GetPrinter(mPrinterHandle, 2, IntPtr.Zero, 0, lBuffLen)
If lBuffLen > 0 Then
Dim lBytesRead As Int32
Dim lBuff As IntPtr = Marshal.AllocCoTaskMem(lBuffLen)
lRetCode = GetPrinter(mPrinterHandle, 2, lBuff, lBuffLen, lBytesRead)
If lRetCode > 0 Then
Dim lInfo As PRINTER_INFO_2
lInfo = Marshal.PtrToStructure(lBuff, lInfo.GetType)
lInfo.pDevMode = mMemBuffer
lInfo.pSecurityDescriptor = 0
Marshal.StructureToPtr(lInfo, lBuff, True)
' HELP!!!
' This always fails with Err.LastDllError = 5 (access denied)
' This makes me think that there is someting wrong with the
' security descriptor.
' HELP!!!
lRetCode = SetPrinter(mPrinterHandle, 2, lBuff, 0)
If lRetCode <= 0 Then
lRetCode = Err.LastDllError
End If
Marshal.FreeCoTaskMem(lBuff)
Return True
End If
End If
Return False
End Function
Public Sub Dispose() Implements System.IDisposable.Dispose
If mPrinterHandle > 0 Then
Close()
End If
End Sub
End Class
Nursey
|
|
|
|
|
"I think you either know the answer to this one or not. I don't want speculcation and supposition"
hmmm... I'm not sure how to respond to that but, here goes.
I built your software using vs.net 2003, just as it is listed, on my win2k3 server, as Administrator, I tested it against my HP LaserJet 4100 DTN (with Duplex Mode), I had no permission errors, nor any errors of any kind, but your software also doesn't set the duplex mode for it either. It does however, bring up the printer settings dialog box where I can set it to duplex.
|
|
|
|
|
Thank you so much for going to all that effort. However, if y ou find these two lines of kludge...
mDeviceMode.dmOrientation = 2
mDeviceMode.dmDuplex = 2
You'll see that I do 'try' to set some properties, BUT, and this is where I have to thank you again. I didn't set the field mDeviceMode.dmFields, to tell the driver it needs to reset those two values, duplex and orientation. So you certainly helped me find a bug in my test case. I am not sure why I get the problem of Access Denied and you don't though. I wonder if its anything to do with the way we setup Win2k3 here. Win2k3 is my box and I guess that's subject to the SOE setup used at work. Perhaps I can do a fix and send you some more code to test, would that be ok.
Again, thanks a bunch!
Nursey
|
|
|
|
|
Yes I will be Happy to test it again, also I Do happen to know or at least have a good probable "Idea" of why yours is failing with error 5.
1) OpenPrinter will not connect directly to a network print queue device or driver.
2) If your's is set that way and I suspect it is, (and it does fail with error 5, on mine here also, from a networked windows XP machine.) you need to create a local device that points to the network printer, then create a local print queue by performing the following steps:
From a command prompt, type
NET USE LPT2: \\<printer server="">\<printer> /persistent:yes
to map the local LPT device to the network printer.
Add a local printer in the usual way (go to Start, Settings, Printers, and click Add Printer).
Specify a local device you made above (LPT2), and configure the new printer.
You Must have a local printer device for it to work at all.
3) It will not work at all on any LPT Device above LPT2.(At Least not on my equipment.)
and I go up to LPT4 so it must have a problem with High Irq's also.
Glad to help.
|
|
|
|
|
This is why I put things like "don't answer unless you know the answer", because every so often then it reduces the clutter and gives a guru a chance to get through! 8-)
I will try and map the local port and give it another spin.
I would never have found this information other than by your gratious efforts.
Many thanks.
Nursey
|
|
|
|
|
I captured LPT2, having added a local printer using the same driver, but I get the same result...return code 5 when calling SetPrinter.
You said >>OpenPrinter will not connect directly to a network print queue device or driver
But everything works really well in terms of reading things about the printer, i.e. its name, location, capabilities etc.
Any other thoughts?
Could there be some kind of policy enforced by our network people that could affect this. Sorry I don't know too much about domains and server configs. My machine is a Win2K3 box, but it log into a corporate domain. I wotk for the ministry of justice in Perth, Australia, so I reckon you can guess that things are pretty well tightened up in terms of security policies and the like.
It doens't change anything if I login into my box as an administrator. I normally log in to the domain and develop.
Thanks again.
Nursey
|
|
|
|
|
Yes, I'm sure they would be Inforcing a group policy on the printers, and when you log into the domain the policy automaticly set's your computer also.
Before I go on...
Where is the physical printer at, your place or at work?
|
|
|
|
|
The printer is at my workplace, I just add printer, it's shared from an old server, I looked it up and added it. I can obviously print ok. I can set duplex printing from Word, and print in the normal way. I just have to be able to set duplex on and off from code for some special cases.
BTW, would you rather email me to save time on here? chris.nurse@justice.wa.gov.au
Thx.
Nursey
|
|
|
|
|
I can give your email a try, but I am on the other side of the world from you in the US, so It may be faster to us CP, but I'll give it a try and see.
|
|
|
|
|
Can I just ask, did you actually step the code and look at all the dll last error codes? If so are you saying you didn't get any occurences of error 5 anywhere?
Ta!
Nursey
|
|
|
|
|