|
hi!
I am trying to display my sql data in a textbox by using the following code; this is after i have made connectiions using sqlconnection with sqldataAdapter with also a dataset
the problem code is:
sqldataAdapter
dim dr as Dataset2.CashierRow
me.TextBox2().Text()=dr.CashierId.toString
|
|
|
|
|
kewyn wrote: me.TextBox2().Text()=dr.CashierId.toString
That's not going to work. At best, you'll get "System.Data.DataRow" in the Textbox. You have to write the code that takes each row in the datatable in your dataset and formats the data in each column of that row into whatever form you need. The DataSet class doesn't know anything about how to format your data and doesn't know how to convert it's tables into formatted text strings. It's not supposed to know.
You also don't need to specify Me, and don't need to put the parenthesis after each object or property name.
TextBox2.Text = String.Format("{0} {1}", dr.columnName.Value, dr.columnName.Value)
|
|
|
|
|
I am truly stuck on this and I need despriate help with this. I have posted on MSDN and on VBforums and have no responce. I seriously need this done and I have no idea how to do it.
I am continually throwing around Ideas on how to install printer on LPR port. Here are the givens:
Port: LPR
Server providing LPD: at-cetus.ad.ufl.edu
Queue Name: CSE-211-CLQ
Driver Name: Xerox Phaser 7760GX PS
INF File Name: 7760.inf
I have tried using the registry edits to create the port and that did not work (or I have done it wrong). I have tried NshNetwork:
Code:
WshNetwork.AddWindowsPrinterConnection("\\at-cetus.ad.ufl.edu\CSE-211-CLQ", "Xerox Phaser 7760GX PS", "LPR")
However in NT and Later the LPR is ignored and I can't figure out how to get it to point to the correct inf file and crate the port. I have tried
Shell("rundll32 printui.dll, PrintUIEntry /if /b ""test_1/"" /f ""C:\7760.inf\"" /q /r ""at-cetus.ad.ufl.edu:CSE-211-CLQ/"" /m ""Xerox Phaser 7760GX PS"" /z /u")
However I can't seem to get that to work either.
Lastly I have tried Prnport.vbs as so:
Code:
cscript prnport.vbs -a -r cse-211-clq -h at-cetus.ad.ufl.edu -o lpr -q CSE-211-CLQ
But the Vista machine does not have that and I am not even sure about XP.
I am looking at WMI, however I am completely lost. PLEASE HELP! What am I doing wrong???
|
|
|
|
|
I haven't done this and I can't test it since I don't have any LPR servers around, but I think the command is:
cscript prnport.vbs -a -s serverName -r LPR -q queueName
|
|
|
|
|
However prnport.vbs is non-existent in Vista.
|
|
|
|
|
I have been searching the web high and low for anything that tells me if and how I can take a pdf and insert an image in a certain area on the document.
Does anyone know of a way to do this?
Thank you.
|
|
|
|
|
Youneed a third party PDF library to do this. Exactly how you do it depends on the library that you use. Consult it's documentation. You might want to look at this list[^] for some libraries.
|
|
|
|
|
I have the following code which works if ran on the server:
dim strProcess = "D:\Application\test.exe"
Process.Start(strProcess)
If I do this it won't work:
dim strProcess = "\\ServerName\Application\test.exe"
Process.Start(strProcess)
I can run this (\\ServerName\Application\test.exe) manually on the server, but if the service application I wrote tries to start the process, nothing happens?
Why? Any suggestions?
Lost in the vast sea of .NET
|
|
|
|
|
You could try shelling to the program, or declaring the process?
Dim sysPath As String = \\ServerName\Application\test.exe
Shell(syspath, AppWinStyle.NormalFocus, True)
Declare process
Dim udtProcess As Process = New Process
udtProcess.Start(strProcess)
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
Got zinged on the previous reply..............but don't know why. Give some constructive criticism so that we can all learn - thanks!
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
It's not clear where the code is stored and where it's supposed to be running. If I understand you correctly, your VB.NET code is running on a workstation, loaded from a local (non-network) source and it's trying to launch another executable from a network source?? Correct?? What type of .EXE is this second executable?? Is it a .NET app?? (Yes, it matters!)
|
|
|
|
|
The application is a VB.NET VS 2005 windows service running on a test server. The main job of this service is to look at specific network locations and if a file is put in one of these locations the service "Starts" a VB.NET application to process the file.
We had an older windows service application written in VS 2003 which used the Process.start syntax and worked well with \\Server type of addresses to fire off an executable.
The new VS 2005 app which is basically the same with a few timer enhancements to control the timing a little more, fires off applications that are defined as D:\folder\app.exe without any problems using the process.start syntax.
The executable it is firing off is a .NET 2005 with Install mode and settings under the publish option set to "application is available online only".
I tried the Shell logic locally by installing the service using InstallUtil to my system and it seems to be working better than the Process.start logic.
I have to build the setup and install it on the server to see if it works, but so far, so good.
My question, is which syntax is better. Some people would say whatever works, but I always take the approach where I like to use code that is considered correct and the latest rather than obsolete or older syntax that might not be the best way for performance or other reasons.
Any suggestions are appreciated. Hopefully this info helps and makes sense.
Lost in the vast sea of .NET
|
|
|
|
|
What account is this service running under?? If it's the LocalSystem account, it doesn't have any access to network resources, so it can't map drives to network shares and can't use UNC paths to get to them either.
There is no difference between Shell and Process.Start. They do the exact same thing using the exact same Win32 API's to do their work. Shell is outdated and not guaranteed to be there in future versions of VB.NET. It's only there for backwards compatibility with VB6 code.
You service needs to be running under an account that has permissions to the network resources you're talking about in order to work properly.
Is this "D:" drive a local drive to the workstation running the service?? Or is it a mapped drive to a network share?? If so, is there a login script that maps this drive when the user logs in??
|
|
|
|
|
> What account is this service running under??
Network logon we use for these type of applications with administrative privileges and access to all the network locations I'm trying to reach. This is also the network login I use to sign onto the server and setup scheduled tasks, etc.
> Shell is outdated and not guaranteed to be there in future versions of VB.NET. It's only there for
> backwards compatibility with VB6 code.
That is what I thought. I don't want to write code that is not guaranteed to work in the next release and forward if I can help it.
> You service needs to be running under an account that has permissions to the network resources
> you're talking about in order to work properly.
I can run the application from the server signed on with the same credentials and it works like a charm.
> Is this "D:" drive a local drive to the workstation running the service?? Or is it a mapped drive
> to a network share?? If so, is there a login script that maps this drive when the user logs in??
The D: drive is a local second hard drive on the server. If I locate the application on this drive and have the service start it, everything works fine. If I keep it on the other server where it should be, I can start it manually, but the service doesn't want to fire it off.
Lost in the vast sea of .NET
|
|
|
|
|
Was this second .EXE written under .NET (C#, VB.NET)??
If so, then you're running into the Code Access Security problem where code running from a network source is not trusted. You have to tell the .NET CLR on the machine running the code to trust the network location the code is stored on or sign the code and tell it to trust code signed with a ceratin certificate.
|
|
|
|
|
> Was this second .EXE written under .NET (C#, VB.NET)??
Yes
> If so, then you're running into the Code Access Security problem where code running from a network
> source is not trusted. You have to tell the .NET CLR on the machine running the code to trust the
> network location the code is stored on or sign the code and tell it to trust code signed with a
> ceratin certificate.
I'm going to look into this. I've seen this problem in the past and we even have a MSI file that we created to set security on workstations. I'm going to review our documentation and tweak the server with these settings and see if it helps.
Thanks!
Lost in the vast sea of .NET
|
|
|
|
|
Just remember, you have to tweak the machine that's going to be running the code, not the server where it's stored.
|
|
|
|
|
The code running is on a server and the service calling the code is on another server. Both servers are set to full trust on the code access settings for intranet in the 1.1 configuration tool found in administrative tools.
Unfortunately both apps (Service and code we're running are 2005 framework 2.0). Where do we find the configuration tool for 2.0. The framework is loaded, but the tool is not there. Is it a seperate install or is it a different process entirely?
Thanks for all your help. I believe this is definitely the issue. I'm heading out for the day, but will check for a reply if you have a chance in the remainder of the day to reply.
Thanks again!
Lost in the vast sea of .NET
|
|
|
|
|
Get the Dot Net 2.0 SDK and use mscorcfg.msc in the run window.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
I installed the Framework 2.0 SDK on the server, went to administrative tools, configuration tool for framework 2.0 and moved the Code Access Security for the Intranet Zone to Full Trust.
Restarted my service and it worked without a hitch.
Thanks for all your help!
Lost in the vast sea of .NET
|
|
|
|
|
Thanks for all your help! The code access security change worked!
Lost in the vast sea of .NET
|
|
|
|
|
One problem may be that the server process which tries to execute the program is running on different credentials (for example under local system) than what you used when you tested starting the program.
Also catch all exceptions and write them to a log or whereever it's easy for you to check if the call failed.
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
I agree with catching all exceptions and the service is processing the code. Nothing fires however. I tried mapping the network directory on the server and for some reason when the service runs under the same network credentials as the login that I created the mapping it didn't recognize the path. It bailed and was caught by the try/catch logic.
Like I said the credentials for the service firing off the executable is using a network credential with administrative privileges.
The shell logic which was the first reply seems to work but I'm not sure why the process.start logic doesn't.
Any other suggestions are appreciated.
Lost in the vast sea of .NET
|
|
|
|
|
I would try this. Create a new generic win app to test with. Use the following overloaded version of the process.start method.
Public Shared Function Process.Start ( _
fileName As String, _
userName As String, _
password As SecureString, _
domain As String _
) As Process
Get it to work from the generic app and then change your service as needed. Services can be hard to debug. Ensure when the service is installed that the credentials on the service are correct as well (right click the service in the control panel and change as needed).
If push came to shove, you could call something like CreateProcessWithLogon or do the generic shell:
Declare Function CreateProcessWithLogon Lib "advapi32" Alias "CreateProcessWithLogonW"
If someone wants to ding me on the score fine, just let me know why. Thanks.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
modified on Thursday, October 23, 2008 2:29 PM
|
|
|
|
|
KreativeKai wrote: I tried mapping the network directory on the server and for some reason when the service runs under the same network credentials as the login that I created the mapping it didn't recognize the path.
This is because any mapping you make is specific to your logon session. Any other session using the same credentials will not see any drive you map. That's why I asked if the drive is mapped from a login script. Services run under their own login session and under an entirely different desktop. They (normally) have no idea, nor should they even care, if a user is logged on or not.
|
|
|
|