Web site not pulling data properly from SQL after server transfer - sql

We have a website we would like to transfer to our Server 2008, IIS7 site which uses NOPCommerce. We imported the database, set up the web.config and the database connects. The issue, it seems, is that it's not pulling the data.
For example: The registration page should be like:
First Name
Last Name
Gender
Birth Date
Instead its like
account.firstname
account.lastname
account.gender
account.dob
We ensured the site has proper access to the DB and it does connect(it yields an error page if it doesn't)
Anyone have any ideas?

Seems the issue was related to mounting the database. It seems the primary keys were set to the lowest available value instead of the proper one,

Related

How to use SQL Server Reporting Services URL Access to save rendered PDF-Reports as varbinary into Table

I'm trying to store rendered pdf-reports from the Report Server back into a table of the origin database as a varbinary. My current approach would be to use URL-Access inside of an external python script to get the rendered reports and then save them into the corresponding table. The following URL works as expected in the browser:
http://localhost/reportserver?/ReportingServicesTest/Report_Test&rs:Format=PDF
However when I tried to access that URL inside of the external python script I received a 401 error.
So I then tried to use the requests_ntlm library to pass the username and password, but somehow it still doesn't work.
import requests
from requests_ntlm import HttpNtlmAuth
url = 'http://localhost/reportserver?/ReportingServicesTest/Report_Test&rs:Format=PDF'
session = requests.Session()
session.auth = HttpNtlmAuth('Domain\\Username','password')
response = session.get(url,stream=True)
open('C:/Path/Report_Test.pdf', 'wb').write(response.content)
Is my approach in principle correct or are there better ways to accomplish the same thing?
I'm fairly new to SQL Server Reporting Services, so I'm open to your suggestions and appreciate your help in advance.
IMHO if you need to historic data for safekeeping or auditing purposes I'd strongly recommend to keep the data in the database. Use a staging environment to add a timestamp to the report data so the snapshots make more sense. In this way you can use the SSRS portal later on to filter on a particular historic version (parameterized) and you don't have to build a bespoke PDF viewer. It would also save some database storage. As an alternative, you could create a subscription in SSRS, have the PDF send to a file share. Then configure a listener to that directory to get your meta information and store that reference in a database table. Needless to say I'm not a big fan of storing files in the database as file storage is cheaper than database storage most of the time.
To solve your authentication issue you might want to check up on your rsreportserver.config file on your web server as your current code suggests that your local host is unknowing of any domain. In any case you can try changing your <Authentication/> section so that it looks like this:
<Authentication>
<AuthenticationTypes>
<RSWindowsBasic>
<LogonMethod>3</LogonMethod>
<Realm></Realm>
<DefaultDomain>putyourfullyqualifieddomainnamehere</DefaultDomain>
</RSWindowsBasic>
</AuthenticationTypes>
<RSWindowsExtendedProtectionLevel>Off</RSWindowsExtendedProtectionLevel>
<RSWindowsExtendedProtectionScenario>Proxy</RSWindowsExtendedProtectionScenario>
<EnableAuthPersistence>true</EnableAuthPersistence>
</Authentication>
This will also work if your web server is behind a proxy or firewall.
Important: the content of DefaultDomain should be a FQDN, such as contoso.microsoft.com or myprimarydomain.lan

Migrating Database to new server when there are many references in Excel

At work we are trying to upgrade infrastructure and finally separate app servers and database servers. We would like to migrate our current SQL server DBs to a new database server, but we have many Excel spreadsheets around the office that have database connections and data sources that link to our current db server.
Finding all of those references would be a fairly monumental task. Is there any way to re-route all of these data sources without having to find and update each Excel file that is out there? We're not even sure that all of these use consistent drivers, some may be ODBC, a lot are definitely OLE, some may even use ADO.Net through Excel Macros.
Does anybody out there have experience with a situation like this? Any help is greatly appreciated.
Assuming the connection to the SQL Server in the excel spreadsheets made by DNS name and not IP, then the following procedure will do the work:
Setup the new server with a new host name, a new DNS record , like there's a standard new installation.
Move your data & configuration to the new server. remember to move logins and make sure they mapped correctly.
Change the name of the old server. Make sure the old name is not referenced by the DNS anymore.
Add new DNS record (A record) to your DNS server, referencing to the IP of the new server. (BTW, you can also use WINS/SQL Alias, and not the DNS server way)
Now, the old name is referenced to the new server IP. BUT, connections won't work in AD environment because of the Kerberos protocol. to make it work, assuming the server's new name is newname.ADDomain.com, and the service account of SQL Server is ADDomain\sqlsvc, run the following command on the SQL server: SetSPN -S MSSQLSVC/newname.ADDomain.com:1433 ADDomain\sqlsvc. if you're not in domain environment or not using windows authenticaiton you can skip this step.
After you done, clients will be able to connect the new server with the old name. I suggest that before doing this procedure you'll make sure you know how to do it and how to roll-back in case it's needed (which means, making sure you know how to get the old server up and running with the old name).
If you want to be on the safe side, and ready for future changes, you should consider making a little change: instead of using the old name as an alias to the new server, set up AlwaysOn cluster, and use this old name as the name of the listener, and not the name of the new DB server itself.
this way, future moves will be easier, as the clients will always use the listener name to connect and AlwaysOn will route them to the active server.
Hope this helps.

Connection Error with SQL Azure and Entity Framework on Azure Website

Not sure where to start, but whenever I publish my ASP.NET website to Azure, any pages which have database access give me a message saying "Error. An Error occurred while processing your request." I open up the remote debugger (which is fickle because it refuses to attach half of the time) and I see the error occurs when establishing when trying to access Entity Framework. The error varies between a "network-related or instance-specific" error, or a "Login Failed" error (which could be the result of the previous error, I really don't know).
The ADO.NET connection string SQL Azure gives is
Server=tcp:[servername].database.windows.net,1433;Database=EnsembleMusicWebDatabase;User ID=user#[servername];Password=(password);Trusted_Connection=False;Connection Timeout=30;
But every implementation (inserting that into EF metadata string, changing the server to data source...etc) still gives me the same login error
I'm pretty sure it's a problem with the connection string, but the infuriating part is that I've tried every possible combination I can think of (entity framework metadata, using the SQL Azure database ADO.NET connection strings in any possible way, changing the Azure website connection strings under the Config tab, using just a plain connection string...etc).
I've deleted and rebuilt the Entity Framework models at least 5 times, and every time I can successfully establish a connection to the server and it successfully reads my database and creates the correct models. I deploy the application to localhost and it works. The problem is when I publish, it cannot access the database and keeps giving me these login failed errors (the login details are the exact same as when I set up the EF model).
I think it might be something to do with the firewall, since I can access the DB locally with an approved firewall IP on the server config, but the website itself can't access the database (I have the enable azure services box ticked as well). I'm really at a loss for what to do now, because I just want the site (not any user, just the application) to fetch some data from the database and display it on the page, but I don't understand how this could be so complicated.
Can anyone point me in the right direction? I tried every tutorial and example on msdn and I can't find any solutions on SO that work.
Thanks,
Shaun
I realised that I somehow got into a complete mess with connection strings all over the place and the best way to fix it was just to start again. I deleted my Azure website and database instances, built the database first (created a correct login as well) and then when creating a new website Azure gave me the option to include the database I had just created. I now have a correct connection string that Azure generated, but to be safe (because the metadata made connection strings confusing and I didn't want to risk having this same issue again) I'm not using Entity Framework and just using normal SqlClient queries, since the website only requests two objects from a database.
I think now I've got a correct and working string I can look at it and really understand where I went wrong and how to avoid this if I do end up using Entity Framework.

Making OCA with sync service utilize dynamic table name

I'm working an OCA application based on a SQL server db and a SQL CE client db. Each user has there own table in the on the SQL server db. Each user's table has the same schema but can have different data. I'd like to make the synctable name to be dynamically set in the client application based on the their SQL server DB table name (which is set as userID + "__usersdatatable").
The sync service runs without problems when I don't attempt to change anything. My latest idea was to change SyncTable.TableName = "jsmith_usersdatatable"; in the LocalDataCache1SyncAgent.cs in the oninitialized() method. However, I get the following error:
"Unable to initialize the client database, because the schema for table 'zlentz_GOBOS'
could not be retrieved by the GetSchema() method of DbServerSyncProvider. Make sure
that you can establish a connection to the client database and that either the
SelectIncrementalInsertsCommand property or the SelectIncrementalUpdatesCommand
property of the SyncAdapter is specified correctly."
In short the idea is that each OCA will need to sync to a different table (bidirectional).
I'm obviously no SQL or sync Services expert so advice would helpful. :)
Thanks in advanced!
After learning more about the Sync Framework it was apparent that I needed to work outside the wizard.
For future viewers the following link was very helpful:
http://www.codeproject.com/Articles/18027/Take-Data-Offline-Using-Microsoft-Synchronization

Problem writing to a SQL Server 2005 Database from MVC2 App hosted on IIS6

As the title indicates I have an MVC 2 Application running on Server 2003. So, I have IIS6 and a SQL Server 2005 instance on another machine that I am connecting to.
Here's the scoop:
--I have done the wildcard hack to get the MVC routing to work and the site loads correctly.
--I can read information from the database and everything displays fine. (So MVC is working)
--I am using Linq to SQL.
--When I attempt to update data in the database I get an internal server error.
--The website runs correctly and will read and save information to the same SQL server instance when running from Casinni or IIS Express on my development machine.
Some other possibly useful information: I am using Windows Integrated Authentication (the website sees me as the user correctly), the app pool on IIS is running as a user who has both read and write access to the database. I also currently have anonymous authetication turned off, but turning it on caused no change.
Any ideas would be really appreciated. I feel like it's something really simple that I am just missing.
So after long hours on the phone with MS tech support here is the answer:
So if you have a database that contains two tables, both with automatic integer primary keys, and a relationship exists between a unique char field in one and a non-unique char field in the other, inserting new rows into the second table leads to invalid case exception. This exception does not happen when calling to the database from Cassini, IIS7.5 Express or IIS 7.5 but does from IIS.6.0.
I restructured the database to avoid this design architecture and the problem was resolved.