|
Great, just what I was looking for - thanks
|
|
|
|
|
For my project, I have setup a small domain, and arranged a LAN connection.
From my domain, when I connect with my Sqlserver 2008 remotely It's connected, no problem.And the application is running good.
But when I run the program, out of domain not in LAN, it's not connecting with my sql server and showing the error,
"A network-related or instance-specific error occurred while establishing a connection to sql server......(provider; Named pipes provider, error: 40- could not open a connection to sql server).
Any ideas to fix this problem ?
Thanks...
|
|
|
|
|
What connection string do you use?
My first thought would be your trying to log in to the sql-server using windows-authentication, try providing a login / pass (usually sa / <set during="" installation=""> works)
|
|
|
|
|
Iam using the followings as connection string
Dim ConStr As String = "Data Source=1.1.1.1; initial Catalog=Employee_Master; User Id=Codeproject; Password=xxxxxxxx"
It's cnnecting under LAN, but not with remote machines.
Thanks
|
|
|
|
|
Sounds like an sql-server issue, from what I can remember you have to specifically allow remote connections to the sql-server.
Maybe better to ask this in the General database[^] forum
|
|
|
|
|
Hi,
I have a console application that gathers order data, and creates and sends email messages to sales people.
I run the application in a scheduled task, and the smtp credentials are simply hard coded:
Dim smtp As New System.Net.Mail.SmtpClient("MySMTPServer.MyDomain.com")
smtp.Credentials = New System.Net.NetworkCredential("MyAccount", "MyPassword", "MyDomain")
I run the job under my own account (with power-user rights), because I have no administrator rights to the domain.
What I am thinking about is, that hard coded credentials are ofcourse not ideal to say the least.
My question is, would it be possible to somehow pass the credentials with which the scheduled task is run, to the application?
Any insights appreciated,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
I don't have a problem with the idea of hard coded credentials, after all it is a service that is making the call. I have a problem with the being YOUR creds, you should have a service account set up to run these services with the permissions appropriate to the service.
What happens when your 30/90 days are up and you have to change you password (you do have a policy that requires password changes )
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
The bad news is that we don't have such a policy, the good news is that I don't make the policy.
You have a good point there actually (about the credentials), and as a solution it is much simpler, than the line of thought I found myself stranded upon.
Thanks !
My advice is free, and you may get what you paid for.
|
|
|
|
|
We have a number of accounts set up specifically for different server jobs from SSIS to reporting and some WCF services, this is over and above the accounts that support the sa in each server.
We do have such a policy, even on the servers and their accounts, thakn God I don't have anything to do with it. The have scripts that change the passwords on all the 1000+ servers, including oracle, sql server, sybase and a couple of other breeds. You should see the chaos when they forget to include a new server in the script.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: thank God I don't have anything to do with it.
I am with you on that one.
Mycroft Holmes wrote: We have a number of accounts set up specifically for different server jobs
We are just a small subsidiary company, so I only need to take care of a relatively small amount of jobs that are specific to just us. Though I am sure that our HQ employs a setup similar to what you describe.
I'll be in contact with them about getting a service account like you suggested.
My advice is free, and you may get what you paid for.
|
|
|
|
|
Hi,
Im trying to make a robot player for a game im playing
so far i have been using a program called JoyTokey which transfers joystick strokes to mouse or keyboard events.
1) i tryed using sendkeys when the window is focused
But i get an error: "The specific module could not be found"
2) i tryed using Sendmessage and no affect,
3) when i right click the application on task manager and click "Go To Process"
i get nothing, and i cant find it in the processes in task manager manualy either.
4) when i try hwnd on it i get a number but dont know what to do with it.
any idea how can i solve the problem ?
if i knew how the program JoyToKey works...
thanks.
|
|
|
|
|
See this[^] C# article.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Thanks, ill try it as soon as i get home
|
|
|
|
|
Hi,
I tryed the application,
it detected the window i want but when i tryed to send a key stroke
it crashed, I looked in the debugging information and guess what i found,
the same error i recieved :"The specific module could not be found"
so i guess he used Sendkeys too (i didnt look in the code, only runed the app)
and its not working with this specific game.
can anyone help ?
|
|
|
|
|
|
I have a VB.NET (VS 2008) main form that shows a second form. The second form has a listbox that has lines of data added for an amortization table based on global variables set in the main form.
The second form has an exit button as its only user control. If the user clicks the exit button while the data is still being calcualted and added to the listbox, the button executes me.close and frmMain.show.
The problem is that if a loan with many months (each month is a line in the listbox) is being displayed, then after the form closes and shows the main form, the second form's code is still running in the background. If I select a new set of loan parameters on the main form while the second form's code is still running, I get an error.
What I need to do is close the second form such that all code running in the form is also killed.
I have also tried this version and the "dispose" does not seem to make any difference.
Private Sub btnCloseAmort_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCloseAmort.Click
Me.Dispose()
frmMain.Show()
End Sub
I will apprechiate any help I can get.
William
|
|
|
|
|
1) how are you loading the 2nd form? as a dialog or?
2) how is it that you can say frmMain? you don't have a circular reference do you (gave form2 the pointer to form1)?
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
Welcome!
You need to signal the data add code an exit when form is closing. How is this data add happening? On a separate thread? Also, I'd suggest you to use delegates for communicating between forms.
Probably, you need to show us the code you are using to get more help.
|
|
|
|
|
The code that is running to populate the frmAmort form:
Private Sub frmAmort_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Used as the index for the for loop
Dim i As Int32
' We will be resetting the balance as payments are made so we need a starting balance
Dim dBalance As Double = dPrincipal_g
Dim dInterestPaid As Double
Dim dPrincipalPaid As Double = dPayment_g - dInterestPaid
Dim loops As Integer = 0
lblHeading.Text = "Pmnt# Balance Interest Paid Principal Paid"
' Loop for every payment
For i = 1 To iMonths_g
' Calculate the amount of interest paid for that month
dInterestPaid = Math.Round(((dBalance * dInterestRate_g)), 2)
' Calculate the balance after the payment for that month
dBalance = dBalance - dPayment_g + dInterestPaid
' Calculate the amount of principal paid for that month
dPrincipalPaid = dPayment_g - dInterestPaid
loops += 1
' Display the amounts in the listbox
If dBalance > 0 Then
lstAmort.Items.Add(i & Chr(9) & FormatCurrency(CDec(dBalance)) & Chr(9) & _
FormatCurrency(dInterestPaid) & Chr(9) & FormatCurrency((dPrincipalPaid)))
Else
' If the number is too small, it will not tab properly so add an extra tab.
lstAmort.Items.Add(i & Chr(9) & FormatCurrency(CDec(dBalance)) & Chr(9) & Chr(9) & _
FormatCurrency(dInterestPaid) & Chr(9) & FormatCurrency(dPrincipalPaid))
End If
' Cause the form to display the values without waiting until control
' is returned to the form (process all messages in the queue).
Application.DoEvents()
'If we have displayed 36 months of data, then pause
If (loops = 36) Then
'pause the display 2 seconds (2000 milliseconds)
Threading.Thread.Sleep(2000)
' reset the loop counter
loops = 0
End If
lstAmort.SelectedIndex = i - 1
Next
End Sub
Private Sub btnCloseAmort_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCloseAmort.Click
Me.Close()
frmMain.Show()
End Sub
Thanks again for looking into this for me. the pausing is not an option. USing a gridbox maybe but I am not there yet in my training.
William
|
|
|
|
|
Hi,
first of all:
1) welcome to the CodeProject
2) IMO most replies you've got are not touching the heart of the problem you have.
Here is how I see it: there are basically three problems.
1) you have a potentially slow calculation executed inside the frmAmort_Load() method; this is bad, since it will block normal GUI operations for as long as it takes. A typical GUI guideline says you should make sure the GUI always responds "immediately", meaning no handler should ever take more than say 30 msec to execute. If more work needs to be done, you should delegate that to another thread (and take the required actions to get the data correctly to the GUI Controls).
2) to "remedy" (or really: hide part of) the problem, you have added an Application.DoEvents() call which makes sure some Controls get updated before the handler is done (that is what you wanted), however it also will process whatever other Windows messages it can find, such as the clicking of the close box. That is how you are able to close the form that is still being loaded.
3) you have a Thread.Sleep inside a handler, that is a big no no. You should NEVER do that, for the very same reasons mentioned above.
Here is what you should do as a minimum:
1) remove the Thread.Sleep
2) replace the Application.DoEvents() by either nothing or by lstAmort.Refresh()
(chances are without the Sleep, the entire Load is almost instantaneous, unless you need hundreds of lines in the list)
And here is what a decent approach would be assuming a really long calculation;
1) the above minimum fixes;
2) plus moving most of the Load stuff to a BackgroundWorker, and using Control.Invoke to update the lstAmort Control. See this article[^] of mine, and the BGW documentation.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hmm ... Why would you use a listbox instead of the more powerful, DataGridView.
I would load the datatable first, then bind it to the grid and it would be displayed to the user. By doing this, you are sure that the data is fully loaded before the grid displays. I'm also kind of suprised that there is such a delay in loading an amortization schedule that the user could close the form before it finishes loading. A 30 year mortgage is only 360 lines; you should be able to load that in 1 or 2 seconds.
Give us some more info and we should be able to point you in the right direction.
|
|
|
|
|
If you want to show two different forms, but not both at the same time, the best way to do it, is to define both forms as controls, and put both controls on the one form, switching which one is visible.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hey..
I really at my wits end on this.
I have a device that i connect to through TCP/IP using an api function call.
Because there could be cases where maybe the router/switch restarted or the network went down or something
and if this happens then the device should connect automatically again.
I need a to check the the connection status of the device,whether it is connected to application or not so then i can reconnect automatically.
I did something like this
Dim information As TcpConnectionInformation
For Each information In IPGlobalProperties.GetIPGlobalProperties.GetActiveTcpConnections
If (information.RemoteEndPoint.Address.ToString = readerIp) Then
state = CInt(information.State)
End If
Next
However this updates the state only after i manually disconnect the device.It the i pull the cable out and plug it back in it still show the same state.
Is there another way to this,to check where a connection is..(not like ping) but if there is an active connection between the device and pc.
|
|
|
|
|
AFAIK, ping[^] is the efficient way for this. Just ping the device and if you are getting acknowledgement, consider it as active.
|
|
|
|
|
i know but ping will only tell if the device is connected to the network..it will not tell me if there is an active connection(ie that there is some data flow between the device & pc).
For instance the device is connected to my application(i can ping it as well)...however if i pull out the cable and plug it in back again..i can still ping it...but it isn't connected to my application anymore...so the ping check is not enough for this..it wont tell me if it is connected or not..is there some way to do this with sockets and ports?
|
|
|
|