|
You guys are AWESOME...
Total team effort.
I thank M-Hall and Twofaced for their assistance.
|
|
|
|
|
Hi there,
I have a windows application and I need to show some pictures that stored in the server. PictureBox could not show these files and I tried impersonation. But it still throws exception saying 'Unauthorized user'. How can I make the picture box show these images? Thanks a lot...
(I have to write image address like; 'http://server/images/image.jpg'
Savas
|
|
|
|
|
If this is a local server it would be "\\server\images\image.jpg".
Cleako
|
|
|
|
|
Images directory is a virtual directory and I don't know where it is. Actually this is a part of web application (but windows application). So I have to write 'http://server/images/'
Savas
|
|
|
|
|
Ahhh, ok. Well in that case the IIS is most likely what is preventing you from accessing the location. You will either need to adjust the permissions of the directory or IIS in order to get this to work.
Cleako
|
|
|
|
|
Hiya
Does anyone know how to download information from Exchange server?
Not the best way to ask a question but what i'm trying to do is retreive all the information from the shared calander in Outlook.
E.g. Ger - Meeting
i need to get this information in a database
Does anyone have any ideas???? Please?
You are you and I am I. So who is that?
|
|
|
|
|
Hi.
I have a VB NET application that connects to SQL Server and save some data.
When is executed from Windows is OK, but when I try to execute it from VBA (in this case, an Outlook Macro) I get several exceptions.... Like:
... "an error has ocurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections"...
Or some other Cast Exceptions...
I've tried with Shell, or the ShellExecute API....
What I'm doing wrong?
PD: Sorry for my English...
|
|
|
|
|
Are you trying to run this application on a server that doesn't have anyone logged in? The error you gave usually happens when you can not reach the sql server. Is there some reason why you wouldn't be able to access the sql server from the PC you are trying to run the VBA script?
Hope that helps.
Ben
|
|
|
|
|
Hi Kubben.
The application is in the same server as the SQL Server.
In fact, when I run the application in that server from the "Run" command on Windows, it runs perfectly. Is only when is executed from the Outlook Macro (in the same server) when I get the exception.
|
|
|
|
|
So you are logged in when the macro gets run? If the macro is getting run when no one is logged in, I can see where you could be having some problems.
I am starting to wonder if you need a entry in your hosts file on that PC.
C:\windows\system32\drivers\etc\hosts
You put in that computers IP address and the sql server name.
DNS should work to find the sql server, but it may not work since you are already at the correct sql server.
Anyway just some thoughts.
Hope it helps.
Ben
|
|
|
|
|
Yep. I'm logged in when I run the macro, and I have that server on my DNS.
The problem is not only when connecting to SQL Server, also, when I try to CAST "TRUE" (String) to TRUE (Boolean value) I get a Cast Exception. But that only happens when the application is running INSIDE the Macro.
Thanks anyway kubben.
|
|
|
|
|
If you don't want to have to cast the value you can just the Boolean in from .net and use a bit field in SQL as 0 or 1. I have done that a lot. Anyway, just another idea.
Ben
|
|
|
|
|
I don't know if I have to implement Interop to run my .NET Application in VBA:
ON THE SAME SERVER, LOGGED WITH ADMIN RIGHTS
FROM THE RUN COMMAND ON WINDOWS
"X:\MyPath\VBNETAPP.exe" "Param1" -> It runs fine.
FROM VBA (Outlook Macro)
Call ShellExecute(1, "", "X:\MyPath\VBNETAPP.exe", "Param1", "", 1) -> SQL Server AND Cast Exceptions.
|
|
|
|
|
If you are getting a cast exception, it must mean that your boolean value in your string "true" and "false" is not getting properly set. The only way you would get an exception is if the string is coming across as "" which wouldn't cast to a boolean. I am guessing that your parameters that you are passing into your exe are working different. when you call it from the run command it works as expected. I am wondering if the parameters that are getting passed in from the ShellExecute are adding some addional parameters so you are off by one. I would put a MessageBox.Show( in your form load to see what your input parameters are.
Hope that helps.
Ben
|
|
|
|
|
I switched the boolean code to use 1 or 0.
I used the MessageBox.Show and the parameters are fine, and I'm still having problems when connection to the SQL Server (the connection string is fine too).
|
|
|
|
|
I don't know if you are using a sqluser and sql password for your connection string. If you are not it might be worth a try. Perhaps using the ShellExecute is causing the NTAuthentication not to work. Assuming you are using NTautheication in your connection string.
Ben
|
|
|
|
|
Yeah... That's what I think at first...
I'm using SQL both, SQL and Windows Authentication, and.... nope....
¿Any other ideas? ¿Do you think is something related to Interop?
|
|
|
|
|
I am kind of running out of ideas. So the cast error has gone away? What is the exact error coming from SQL? I am still thinking that the start up or the form load event isn't working as expected.
Ben
|
|
|
|
|
I'm still having the cast exceptions, so I've stop using the convertion from String to Boolean, so that is not a problem (for now....)
The exact SQL exception is:
... "an error has ocurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections"... (I'm using SQL Server 2000)
And I'm sure the start up method is working fine....
I'm already out of ideas...
|
|
|
|
|
That is really weird. The only time I have gotten that error is when the sql server was actually down. I guess the only other thing I can think of, which I think you already checked is what the connection string it right before you open the connection in the vb.net app.
Ben
|
|
|
|
|
I checked the connection string again.
I'm using a configuration file to load some connection options, and it appears that when is executed from VBA the options "loaded" are blank....
I don't know why, but at least i know what the problem is.
THANKS A MILLION BEN!!!!!!!!!!!!!!!!!!!!!!
-- modified at 18:13 Wednesday 21st February, 2007
|
|
|
|
|
Basically i have a listbox and need to take each item (string) out of that listbox to populate textboxes, so the first listbox item goes into the first textbox, second to second etc...
Here is the code that i have for this that works.
For i As Int16 = 0 To lstListbox.Items.Count - 1<br />
Select Case i<br />
Case 0 : txt1.Text = lstListbox.Items(i).ToString<br />
Case 1 : txt2.Text = lstListbox.Items(i).ToString<br />
Case 2 : txt3.Text = lstListbox.Items(i).ToString<br />
Case 3 : txt4.Text = lstListbox.Items(i).ToString<br />
Case 4 : txt5.Text = lstListbox.Items(i).ToString<br />
Case 5 : txt6.Text = lstListbox.Items(i).ToString<br />
End Select<br />
Next<br />
My question is, how do i randomly do this, instead of having the first item go to the first textbox etc, so perhaps having the first item going to the txt5 or txt3 for example and so on.
Help or guidance would be brilliant, thanks!
|
|
|
|
|
You'll need to add each textbox to a list and then randomly select which one you want. Once you pick the textbox you set the text and remove it from the list so it's not chosen again. This should work for you.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'This list will contain our textboxes
Dim itemList As New List(Of TextBox)
'Add each textbox to the list
itemList.AddRange(New TextBox() { _
txt1, _
txt2, _
txt3, _
txt4, _
txt5, _
txt6})
Dim rnd As New Random 'Random number generator
For i As Int16 = 0 To lstListbox.Items.Count - 1
'Pick a random textbox
Dim index As Integer = rnd.Next(0, itemList.Count)
itemList(index).Text = lstListbox.Items(i).ToString
'Remove the textbox so we can't pick it again
itemList.RemoveAt(index)
Next
End Sub
You can write a small routine that dynamically adds each textbox to the list instead of hardcoding them in there, but if you know you'll just want to popullate these 6 you don't have to go to the trouble.
|
|
|
|
|
Brilliant, it works a charm!
Thanks a million TwoFaced!

|
|
|
|
|
where i create internet dialup connection programatically
|
|
|
|