I've an interesting problem. One of my database related code works good on local machine. But it doesn't return anything from when published on the third party web server.
Following is the code snippet :
Public Function getUserAuthDataWithUserId(ByRef Connection As MySqlConnection,
ByVal UserId As String
) As DataTable
Dim cmd As String
cmd = "select * from tbl_md_userauth where tf_userid = '" + UserId + "' "
getUserAuthDataWithUserId = ExecuteSQL(Connection, cmd)
End Function
And the ExecuteSQL function is :
Public Function ExecuteSQL(ByRef Connection As MySqlConnection,
ByVal SQLStatement As String
) As DataTable
Dim ds As New DataSet
Dim da As New MySqlDataAdapter
Try
da = New MySqlDataAdapter(SQLStatement, Connection)
da.Fill(ds, "tbl_Return")
ExecuteSQL = ds.Tables("tbl_Return")
Catch ex As Exception
msgbox ("exception !")
End Try
End Function
Be assured that :
The database table has correct data. And the code works correctly when connecting from local machine to remote desktop.
The code works correctly when using local IIS and local database.
I've also tried republishing the code twice or thrice.
Helpdesk of web server says there is no problem with their server.
Any clue on what is wrong ?
It appears that you are swallowing your exceptions. The code appears to use a msgbox to display the error, but that will appear on the server under a hidden profile and not be sent to the browser for display. You need some other way of displaying or logging the error that works in a web environment.
That being said, are you able to get any connections to the database and just this method is failing, or are all of your database requests failing? I suspect that you are using integrated authentication in your database configuration, but the same user doesn't work on the server because IIS is running as a different user in the app pool. Try changing your development environment to point to your database on the server and see if you get any errors that way. If you are using a hosting environment, I recommend setting up a named user in your database and using that in your connection string rather than using integrated authentication.
Ultimately, it found to be a server side problem. The Helpdesk fixed it. I am yet to know what precisely they have fixed. I'll problably post it over here as soon as I hear from them.
Thanks to all of you guys who've contributed.
Related
I am connecting to an Azure Server to import data hosted by a 3rd party. I can not use Windows Authentication to connect due to security protocols between their company and mine. I have to use server-side authentication with a username and password. I am connecting to Azure using OBDC through DSN. The problem is each time I open Access and connect to the Azure tables, I get a connection error that I have to correct by manually unchecking "Use Trusted Connection" then entering that server's username and password. Is there a way to automate that process?
There are two approaches you can use to fix this issue.
One way, is to delete all your table links, and then re-link. Just make sure you check the box to save the uid/password when you do this. As a result, Access will remember the settings for the lined tables. However, if you “often” or “always” need to prompt the user for uid/logon, then you have to re-link the tables each time. However, if you not needing to re-link or change the uid/password, then this is a simple and fine solution.
Just keep in mind that your uid/password is in “plain” sight the linked tables – so only you can decide if this is a “non issue”, or something that you want to prevent users from seeing.
The other approach is to “leave” your lined tables as they are, and execute a logon in your startup code. Once you executed a logon, then your existing linked tables (without the uid/password saved) will now work.
You can use the following code to “log on” to the server, and once done, then all of those prompts should not appear.
Function TestLogin(strCon As String) As Boolean
On Error GoTo TestError
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Set dbs = CurrentDb()
Set qdf = dbs.CreateQueryDef("")
qdf.connect = strCon
qdf.ReturnsRecords = False
'Any VALID SQL statement that runs on server will work below.
' this does assume user has enough rights to query built in
' system tables
qdf.sql = "SELECT 1 "
qdf.Execute
TestLogin = True
Exit Function
TestError:
TestLogin = False
Exit Function
End Function
You have to pass the above a correctly formatted connection string.
I will try the "log on" technique and let you know how it goes. To give a little more background, I am linked into several backend databases. The ones on on the companyserver auto login using Windows Authentication. The tables on a third party developer's server can not be linked with Windos Authentication due to security issues that poses. The third party connections have to use the developer's login and password.
After hours of searching I finally put a question on here.
Visual Studio is connect to my database perfectly using the Data Source window but can't find the server when using the string (Server=blah;Database=blah etc)
When connecting in my program it breaks with the message:
A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll and The network path was not found
My affected code is listed below.
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
Dim con As New SqlClient.SqlConnection("Server=db4free.net;Database=[CENSORED];Uid=[CENSORED];Pwd=[CENSORED];")
con.Open()
Yes the username, password, server, and database are correct as again, they work in the Data Sources window.
Double check the conection string, it may be changed or mis spelled..
Because If it conects using the data source, then it should connect using connection string too..
Good luck
I am using a TableAdapter in a dataset in Vb.net winforms (connected to a mysql server) to allow integration of a Devexpress scheduler - I have been using this method for some time; while I know of many of the security flaws of vb.net including decompiling and packet sniffing plain text communication; I am trying to lock down security as much as I can which brings me to my current problem.
The dataset was set up to connect using the .net framework data provider for mysql which requests a Server address, username, password, and DB file - I then get the option of "saving the login credentials in the connection string" or "setting the login credentials in my programming code" for sake of time previously I saved the login credentials.
this adds a setting file (connectionstring)
server=mysqlserveraddress.com;user id=mysqluser;password=mysqlpassword;database=mysqldb;persistsecurityinfo=True
which also means these credentials are saved in plain text in the installation folder for my program
I am trying to transition to including this connectionstring in my programming code however I do not know how to approach it - for non-dataset transactions I have already declared public const in a module which includes the credentials
'database variables
Public Const dbserver As String = "mysqlserveraddress.com"
Public Const dbuser As String = "mysqluser"
Public Const dbpassw As String = "mysqlpassword"
Public Const dbfile As String = "mysqldb"
and I create the connections when needed.
How do I programmatically enter the connection string so it is not visible to the lay-person.
Are you saying that you want to to set the user id and password attributes of an existing connection string at run time? If so then you can use the appropriate connection string builder. I don't use MySQL and Connector/Net but it should look something like this:
Dim builder As New MySqlConnectionStringBuilder(partialConnectionString)
builder.UserId = userId
builder.Password = password
Dim fullConnectionString As String = builder.ConnectionString
Anyone who decompiles your code is going to see that data though. You might consider just storing the whole lot in the config file but encrypting it. For more info on that, check this out:
http://www.vbforums.com/showthread.php?532768-NET-2-0-Protected-Configuration-(Encrypting-Config-Files)
I support a LOB application written in MS Access VBA with a SQL Server back end. One feature of the application is the ability to open a second instance of the application, allowing the users to view/modify two records at the same time.
The first time I open the application it connects and everything works fine. However when I attempt to open the second instance I get the following error message:
-2147467259 - Method "OpenConnection" of object _CurrentProject failed.
This is the line of code executing when the error occurs:
CurrentProject.OpenConnection strConnection
I have stepped through the code and verified that strConnection is the same connection string in both the first and second instances of the application
I'm running out of things to look for. Any ideas are greatly appreciated!
UPDATE: It appears that something is not allowing the second MSACCESS.EXE instance to use the same connection string. My connection string is below, with database and server substituted for the actual database and server.
PROVIDER=SQLOLEDB.1;INTEGRATED SECURITY=SSPI;PERSIST SECURITY INFO=FALSE;INITIAL CATALOG=database;DATA SOURCE=server
Try
MultipleActiveResultSets=True
(http://msdn.microsoft.com/en-us/library/h32h3abf(v=vs.110).aspx)
Would it be better to open a new form from the same application?
dim frm as ShowCar_Form
frm.Show
Some users get the following error when running reports.
• Execution 'iwy2vpzo52pmp555ftfn4455' cannot be found (rsExecutionNotFound)
They run fine in the morning.
Any suggestions?
Thank you
I can help.
The problem is that the ReportViewer control uses Session to store the currently executing report. Once you navigate away from the reports, the item still remains and eventually loses its "execution context", which is the way Report Server caches reports.
Therefore, before browsing a report, you should attempt to clear out the Session of these reports, so that there are NO cached reports in the Session, and the ReportViewer control can work properly.
You will also find that sometimes when accessing Session.Keys.Count, this error can occur, as again, the execution context has failed.
Make sure you do this on the page showing the report!!
The 2 options are:
if (!IsPostBack)
{
HttpContext.Current.Session.Clear();
ReportViewer1.ServerReport.ReportServerUrl = new Uri(ReportServerUrl, System.UriKind.Absolute);
ReportViewer1.ServerReport.ReportPath = ReportPath;
System.Collections.Generic.List<ReportParameter> parameters = new System.Collections.Generic.List<ReportParameter>();
....
ReportViewer1.ServerReport.SetParameters(parameters);
ReportViewer1.ServerReport.Refresh();
}
Or
for (int i = 0; i < HttpContext.Current.Session.Keys.Count; )
{
if (HttpContext.Current.Session[i].ToString() == "Microsoft.Reporting.WebForms.ReportHierarchy")
HttpContext.Current.Session.RemoveAt(i);
else
i++;
}
I am using SSRS 2017 and was running into this issue when trying to load a report into my MVC project using URL Access. The issue for me had to do with session.
To check this for yourself, you can try deleting the RSExecutionSession cookie and reload your report. Unfortunately, this is only a temporarily fix.
If this does work, try adding rs:ClearSession=true to your query string.
You can read about this setting here.
Look for a trailing space on the report path. This was the cause for me.
On the web.config's impersonation, use identity
impersonate="true"
userName="xxxxx"
password="xxxxx"
instead of : !--<identity impersonate="true"
Hope it helps
If you're running SQL Server Express edition, the SQL Server Agent isn't running to clean up your old SSRS sessions. You'll need to run a job on SSRS DB to clean up the old sessions.
My report took 10 seconds to run and 2 seconds to export - so it wasn't to do with the session expiry length.
I'd get the error when exporting a report to excel into my app an hour after I exported the report.
This error was causing my application to display a run time error.
I added this to the Global.asax class to resolve the error. Tried Server.Clear but got nothing. Session.Clear got rid of the error completely.
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
If ex.InnerException IsNot Nothing Then
If ex.InnerException.ToString.Contains("The report execution") AndAlso
ex.InnerException.ToString.Contains("rsExecutionNotFound") Then
Session.Clear()
Return
End If
End If
End Sub
While it may not be 100% applicable to the question above, I haven't been able to find any other resolution.