Good day,
I don't seem to find the solution to this problem, maybe by the lack of knowledge to express what I'm looking for.
I'm doing a SQL connection on ASP.Net on Visual.Net 2012, but everytime I try to connect to the SQL Database, it seems to grab my PC name instead of the username I am specifying on the Connection string. I got direct access to the server in-case it is server side problems. Here is a piece of my code.
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
conexion = New MySqlConnection
cadena = "Server=192.168.17.108;User id=root;Database=testing;Password=!Server2013"
conexion.ConnectionString = cadena
End Sub
It is a local server for testing forms, I don't think it is important to hide user/password.
Thanks for your attention!
Edit: Forgot to mention that it is running on a IIS7 on Windows Server 2008
I think you have a dodgy connect string. Take a look at this site: http://www.connectionstrings.com/mysql/ and you'll see that for mysql the connect string is more like:
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
So UID not 'user id', and Pwd not 'Password'
Hence, assuming all else is correct you should use:
Server=192.168.17.108;Uid=root;Database=testing;Pwd=!Server2013
I've set it to Localhost and it worked,(GENIUS), because the app was running on the server. Thanks Cameron Tinker.
And DaveRlz answer also worked to fix my connection string,
Thanks for the replies.
Related
I am developing a web application in asp.net web forms framework. one of the requirement of application is to save records of future appointments of user. User also want to add this appointment to his outlook calendar. Now the problem is that my code is working locally. Appointments are being saved when I test application on my local machine. But when I deploy application on live server code give error and appointment do not saves in my outlook calendar. Kindly help me how to make it work on live server. Following is the code I'm using
Private Sub AddToCalander()
Try
Dim olApp As Microsoft.Office.Interop.Outlook._Application = DirectCast(New Microsoft.Office.Interop.Outlook.Application(), Microsoft.Office.Interop.Outlook._Application)
Dim mapiNS As Microsoft.Office.Interop.Outlook.NameSpace = olApp.GetNamespace("MAPI")
Dim profile As String = ""
mapiNS.Logon(profile, Nothing, Nothing, Nothing)
Dim apt As Microsoft.Office.Interop.Outlook._AppointmentItem = DirectCast(olApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem), Microsoft.Office.Interop.Outlook._AppointmentItem)
apt.Subject = ddItineraryItems.SelectedItem.Text
apt.Body = txtPItinerary_Desc.Text
apt.Start = CDate(txtDateFromPopup.Text)
apt.End = CDate(txtDateToPopup.Text)
apt.BusyStatus = Microsoft.Office.Interop.Outlook.OlBusyStatus.olTentative
apt.AllDayEvent = False
apt.Location = dcmbDealer.SelectedItem.Text & "," & dcmbShowroom.SelectedItem.Text
apt.Save()
Catch ex As Exception
AlertMessage.showError("Unable to add itinerary detail to outlook calendar")
Exit Sub
End Try
End Sub
I get the code from here.
http://www.codeproject.com/Tips/384326/Add-to-Calender-Adding-event-to-Microsoft-Outlook
If you are going to use Outlook by Interop, then you would need to install it on your server. Without installed Outlook - it won't work.
PS. Your code will work only with Outlook account that is configured by default. And it will work only if you are using external service for appointments. Otherwise it will save that appointment just to Outlook on server, without updating it to your local Outlook
And using Interop in web applications on server side isn't a good idea, as it will starts new Outlook process every time, that is very resource expensive. Better way is to integrate with Calendar system that you are using, like Google Calendar, etc.
I've been working on a site to allow clients to sftp data files to us (using SharpSSH.dll) My solution works fine on my development machine but as soon as I move it to production server I am unable to upload.
I know that the problem is because my code is trying to pick up a file on the server when it obviously doesn't exist there so I need some pointers on the best way to resolve this - i.e. how do I adjust my code to allow for an sftp upload from the client machine?
The plan is basically to (and im not entirely sure that I am going about this the correct way) use my web server as a go-between so the client logs on and sftps a file to another server. Advice and pointers are very welcomed - please see code below:
transfer = New SecureFileTransfer("IP", "PORT", "NAME", "PASSWORD")
If transfer.putFile(FileUpload.PostedFile.FileName, company & "/" & filename) = True Then
lblMsg.Text = "File upload complete!"
'write data file details to table
writeAudit()
'check which account manager to alert and send email notification
emailNotify()
Else
lblMsg.Text = "File upload has failed - please try again..."
Exit Sub
End If
Public Sub New(ByVal hostname As String, ByVal port As Integer, ByVal username As String, ByVal password As String)
Me._hostname = hostname
Me._port = port
Me._username = username
Me._password = password
End Sub
Public Function putFile(ByVal localFile As String, ByVal remotePath As String) As Boolean
Try
transfer = New Sftp(Me._hostname, Me._username, Me._password)
transfer.Connect(Me._port)
transfer.Put(localFile, remotePath)
transfer.Close()
Return True
Catch ex As Exception
Dim objWriter As New System.IO.StreamWriter("C:\logfile.txt")
objWriter.Write(ex.Message)
objWriter.Close()
Return False
End Try
End Function
I have checked my sftp credentials and made sure that access from my web server to sftp server is valid and working. My log file is giving me the following exception message:
Could not find file 'c:\windows\system32\inetsrv\x.txt'.
I think I may be misunderstanding how the FileUpload control works here which may well be the crux of the problem
I'm not sure what the exact problem is but I would say that if you have tested your code and are happy it works, then this is not first place to start looking for problems. I would start with the configuration of the FTP server.
Hope this helps!
I have the following code (from msdn) to set file permissions:
' Adds an ACL entry on the specified file for the specified account.
Sub AddFileSecurity(ByVal fileName As String, ByVal account As String, ByVal rights As FileSystemRights, ByVal controlType As AccessControlType)
' Get a FileSecurity object that represents the
' current security settings.
Dim fSecurity As FileSecurity = File.GetAccessControl(fileName)
' Add the FileSystemAccessRule to the security settings.
Dim accessRule As FileSystemAccessRule = New FileSystemAccessRule(account, rights, controlType)
fSecurity.AddAccessRule(accessRule)
' Set the new access settings.
File.SetAccessControl(fileName, fSecurity)
End Sub
I call this using the group IIS_IUSRS (I've tried ComputerName/IIS_IUSRS too) and I'm trying to apply FileSystemRights.FullControl
But results in this error:
System.Security.Principal.IdentityNotMappedException: Some or all identity references could not be translated
Which suggests IIS_IUSRS doesn't exist (it does). My next step is to output the users and groups on the machine to see what my code thinks does exist. In the mean time does anyone know why, or what is causing this?
This code works fine on my local machine but not when run on my web server. The app pool runs as network service and Network Server has FULL permission on the folder the files are in. I noticed this question that suggests the user needs permission on the directory - but this isn't the problem.
To work around this, change the authentication on the website to run as "Same as app pool" (as opposed to anonymous). Not the best answer, but have tried everything else.
I have a Classic ASP page that made an LDAP call to our Domain Controllers to find out the group membership of the logged on user. Since our Network Admin demoted the two old Windows Server 2003 Domain Controllers and promoted two Windows Server 2008 R2 servers the page now fails at Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName) (see code) with the error 800704bc.
Dim Strgroups
Const STAFF_GROUP = "cn=staff"
Const STUDENT_GROUP = "cn=student"
Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
If IsArray(CurrentUser.MemberOf) Then
strGroups = LCase(Join(CurrentUser.MemberOf))
Else
strGroups = LCase(CurrentUser.MemberOf)
End If
Any help is appreciated. Thanks in advance.
I'm guessing it's not the code that's the problem, but rather a something to do with the new servers (obviously).
I don't know what error 800704bc is, but check and see that ADSysInfo is actually getting instantiated. If not, then maybe there's a module missing on the server or something.
Not sure why but I needed to open the high ports (1024+) on the firewall between the server and the DCs. Must be an RPC thing.
Do the new servers block unencrypted binds? If so, then this would make sense as you bind as LDAP not LDAPS nor StartTLS.
I'm at the end of my rope on this. It should be so simple.
I just need to know what's wrong with this connection string:
dbc.open ("Driver={SQL Server}; Data Source = ServerName; Initial Catalog = InitialDB; " "User ID = Username; Password = Password;")
I get this error when running that line:
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
I know ServerName is up and accepting connections, I know InitialDB exists, I know User ID and Password are valid for the database. What am I missing?
In notepad create file anyname.udl - let it be empty. After in explorer click it - you will get a dialog to create OLEDB connection string, select expected driver, and all connection param, ensure that "Allow saving password" = True. Press Ok.
Then again open file with notepad. Content is valid connection string
Try this...
dbc.open ("Provider=SQLOLEDB; Driver={SQL Server}; Data Source = ServerName; Initial Catalog = InitialDB; User ID = Username; Password = Password; Network Library=dbmssocn;")
As someone has already pointed out, udl is the best easiest way to create a conn string - here is a link that talks about it. https://web.archive.org/web/20210211044624/http://www.4guysfromrolla.com/webtech/070400-1.shtml
If you are using ADOdb you might want to try
"Provider=SQLNCLI10;Server=SERVER;Database=DATABASE;Uid=USERNAME;Pwd=PASSWORD"
for SQL Server 2008 Native Client or
"Provider=SQLNCLI;Server=SERVER;Database=DATABASE;Uid=USERNAME;Pwd=PASSWORD"
for SQL Server 2005 Native Client.
For ODBC, use
"Driver=SQL Server Native Client 10.0"
for SQL Server 2008 Native Client or
"Driver=SQL Native Client"
for SQL Server 2005 Native Client.
What's with the " " in the middle of the string?
Your connection string appears to be mixing ODBC and OLEDB. I would suggest visiting http://www.connectionstrings.com/ and finding the correct syntax for the desired provider.
Yours:
"Driver={SQL Server}; Data Source = ServerName; Initial Catalog = InitialDB; " "User ID = Username; Password = Password;"
ODBC:
"Driver={SQL Server};Server=ServerName;Database=InitialDB;Uid=Username;Pwd=Password;"
OLEDB:
"Provider=sqloledb;Data Source=ServerName;Initial Catalog=InitialDB;User Id=Username;Password=Password;"
Do you have visual studio?
Connect to the database server, and locate the database you want to connect to.
Right click, select properties. Your connection string to the db is right there.
Copy to wherever you want. -- Should be in web config, but you can paste it directly into code if you so desire.