How to change my schema for each request? - c#

I would like to change my schema dynamically depending the HTTP Request based on the UserID. I know that the OnModelCreating is just started one time and i try the DB Interceptor with Npgsql but no sucsess !
I have a specific schema by user and i would like to read and write some data inside.
Techno: Asp.Net 4.5
Thank you

In PostgreSQL, the schema that is search/defaulted can be set on the ConnectionString. The parameter is called "Search Path". More information can be found here.
So if you have control over the connectionstring before connecting you can add the parameter ;Search Path=ABC_USERID,public. This says that look to ABC_USERID schema and if it doesn't find it then search in public schema
As long as you don't qualify the table name with a schema it will for the objects in your search path.
-HTH

Related

Adding Schema Name to SQL Table Names in ASP.NET Web Application

I am porting my SQL Server database to Azure SQL. The database has been replicated correctly and is now accessible from my existing web application.
However, the first time it was executed with the Azure SQL connection string, it showed "Invalid Object" for a table name used on the log in page.
I was able to correct it by adding the schema name [dbusername].[tablename] in place of [tablename] in the code.
Now since it is an extensive application, with over 300 ASPX pages and 30 tables, I'm wondering do I have to use the Find-Replace tool in Visual Studio or am I missing a setting that can help me to assign the default schema name while executing all queries ?
Set the default schema for your user.
USE MyDataBase;
GO
ALTER USER MyUser WITH DEFAULT_SCHEMA=MySchema;
GO
I believe this article will help you.
http://blog.sqlauthority.com/2008/12/26/sql-server-fix-error-msg-15151-level-16-state-1-line-2-cannot-alter-the-login-sa-because-it-does-not-exist-or-you-do-not-have-permission/

Passing Values from XML to Web Service Using SSIS

I've been having trouble accomplishing the following task and was looking for input from the community on how I might go about solving it; if this is the wrong place to post this, please let me know and I will move it.
Using a SSIS package I am trying to:
Read values from an XML document.
Pass those values to a web service.
Record the return value in a new XML document (or a flat-file for simplicity sake).
For reference, let's take a simple example. I want to pass a series of currency types to this web service:
http://www.webservicex.net/ConvertTemperature.asmx
So far I have:
Added HTTP Connection Manager - Configured to access the WSDL file at http://www.webservicex.net/CurrencyConvertor.asmx?wsdl
Created a Web Service Task using the HTTP Connection, made and referenced the WSDL file.
The input fields can be selected manually, for example, CAD to USD.
The output can be easily saved to a specified output.
I have two main problems; the first would be passing the columns from the XML source to the web service and the second is I'm not sure how to handle the datatypes of the web service. In the example web service, the datatype for the currency is "Currency" but that is not a defined datatype within BIDS.
Any advice on this matter would be greatly appreciated.
emphasized textcheck out this link which passes data from a flat file source to a web service.
http://www.vsteamsystemcentral.com/cs/blogs/applied_team_system/archive/2007/01/10/247.aspx

Sending a Solr query url in SolrNet

I have a certain url representing a Solr request which I would like to send with SolrNet. The url contains the request handler name and some other parameters such as a stream.url. How do I generate the request using SolrNet and send it to Solr?
Please illustrate the way to do it with a concrete request. For example: http://localhost:8983/solr/mlt?stream.url=http://lucene.apache.org/solr/&mlt.fl=manu,cat&mlt.interestingTerms=list&mlt.mintf=0. Namely, how do I specify in C# code which request handler to use, how do I instantiate all the GET parameters in the above url, and finally, how do I execute the query?
You need to reference the SolrNet Wiki Documentation, specifically the following:
Mapping
Initialization
Querying
More Like This
For additional parameters that are not included directly in SolrNet, see the "Additional Parameters" section at the Querying link above.
Please look through this information and come back if you have any issues setting things up or executing a query.

LinqDataSource is showing Error in DotnetNuke Module

When I am Select Page Setting Option in DNN below error is showing.
Error:
A critical error has occurred. Could not determine a MetaTable. A MetaTable could not be determined for the data source 'LinqDataSource1' and one could not be inferred from the request URL. Make sure that the table is mapped to the dats source, or that the data source is configured with a valid context type and table name, or that the request is part of a registered DynamicDataRoute.
Look at here http://dnnlinqtosqladapter.codeplex.com/ and download sql Model adapter and follow the steps and it can solve your problem.
Try it and let me know about.

reporting services and custom datasource

I'm new to reporting services and ask for the possibily of using custom object as datasource? i'm using asp.net, visual web developer 2008 express edition and c#, if yes can you give an example. thanks for help
You can't use POCO as a data source directly in reporting services. There are a few ways to do this.
The simplest it to save your data to a database and query the database.
You could serialize the object to XML and query that by either including the XML directly into your query in an <XmlData> element, or calling a web service to retrieve the XML.
Create an XML Data Source for a Web Service
In your report project, right click on the Shared Data Sources folder.
Select Add New Data Source.
Set the Name to use.
Set the Type to XML.
Set the connection string to http://MyWebServer/MyWebServiceEndpoint.asmx.
Go to the Credentials page.
Configure the authentication.
Click OK.
You'll need to examine the WSDL for the web service and see the following references to help you build the query:
Reporting Services: Using XML and Web Service Data Sources
XML Query Syntax for XML Report Data (SSRS)
Element Path Syntax for XML Report Data (SSRS)
Here's a list of supported data sources from msdn: Data Sources
You would simply add a shared data source to your project (example: MyDataSource.rds) and choose from the available types. There, you would simply supply the appropriate credentials. Each of your reports would use the data source.
EDIT
Here's a simple tutorial on adding a data source: Creating a Shared Data Source in Reporting Services

Categories

Resources