Azure mobile EasyTables connection string - c#

I am fairly beginner in here, so any help would be much appreciated :)
So, I created a SQL Database and I want to connect EasyTables to it. Apparently the automatic option has been removed and I have to do it manually.
I followed "How can I add a connection string manually" page but it lead me to nothing.
Where should i create the connection string, and what to put in the value field?
Or if there is any tutorials out there for the new way please tell me :)
Thank you a lot

You said you have followed tutorial: How can I add a connection string manually.
The Easy Table connection should like this:
SQL Database Connection String format
Data Source=tcp:{your_SQLServer},{port};Initial Catalog={your_catalogue};User ID={your_username};Password={your_password}
{your_SQLServer} Name of the server, this can be found in the
overview page for your database and is usually in the form of
“server_name.database.windows.net”.
{port} usually 1433.
{your_catalogue} Name of the database.
{your_username} User name to access your database.
{your_password} Password to access your database.
Add the connection string to your Web App
In App Service, you can manage connection strings for your application by using the Configuration option in the menu.
To add a connection string:
Click on the Application settings tab.
Click on [+] New connection string.
You will need to provide Name, Value and Type for your connection
string.
If your are adding a connection string to a SQL Azure database choose
SQLAzure under type.
If your are adding a connection to an Azure Storage account, chose
Custom under type.
NOTE If you are adding a connection string because you are planning on using the Easy API or Easy Table features, then the connection strings used by this features expect the following specific names:
Azure SQL database: MS_TableConnectionString
Azure Storage account: MS_AzureStorageAccountConnectionString
For example, this is my connection string:
When you have configured this, go to Easy table, click Add to add the table name in your Azure SQL database.
You can find that esay table has connected to my Azure SQL database now and we can see the data in the table.
Update:
You should first add the connection string in the configuration followed the format provided for you.
Then go to Easy Table, configure Easy table API:
Choose the 2:
When it done, you can add table in your SQL database, please follow my steps in above.
Note:
Your connection string name must be: MS_TableConnectionString.
Hope this helps.

Related

What Is the Syntax for Including the Service Name in a Connection String?

I have a C# ASP.Net MVC web application. I am trying to successfully connect to an Oracle database.
I am getting a "ORA-12514: TNS:listener does not currently know of service requested in connect descriptor" error.
I do not have access to the server the database is on. But I do have access to Oracle SQL Developer, which I have installed on my machine.
In my C# code I am setting the connection string like this:
ConnectionString = "DataSource=XXX.XX.XXX.XXX/abcd,1521;User ID=userid;Password=password;";
abcd should be the service name. and 1521 is the port number.
I understand that my connection string might not be the cause of the error, but I want to rule it out. Also, I know the more proper way of doing things is probably to set the connection string in web.config and retrieve it as needed, but I am doing it this way just for ease of testing until I know I am able to connect to the database successfully.
What is weird to me, is that I was able to connect to the database using Oracle SQL Developer using the same IP address, port number, service name, username, and password I am using in my connection string.
Primarily, I would like help knowing if my connection string looks valid. If you have additional thoughts about what the issue could be, that would also be appreciated.
using this command in Oracle SQL Developer:
select sys_context('userenv','service_name') from dual;
I am able to determine that the service name I am using in my connection string is one that exists, although I guess this does not guarantee that the service is up.
I am not a DBA by any means. In fact, I am still new to .Net and web development in general, but I have been assigned to troubleshoot this issue. Any help is appreciated.
I don't recall seeing the following format
DataSource=XXX.XX.XXX.XXX/abcd,1521
as valid (which doesn't mean its not, I've just not seen it).
The more common ones I've seen are:
DataSource=XXX
where XXX is a reference to your tnsnames.ora file
DataSource=//nnn.nnn.nnn.nnn/service_name
DataSource=//nnn.nnn.nnn.nnn:port/service_name
So maybe try those variants and see how you go. There's also more definitive list of alternatives at https://www.c-sharpcorner.com/UploadFile/nipuntomar/connection-strings-for-oracle/
I ended up figuring this out. My connection string format I don't t think was correct. I changed it to be:
ConnectionString = "DataSource=XXX.XX.XXX.XXX/abcd;User ID=userid;Password=password;";
Basically, I just took off the port number. In my case, the default port was what I needed anyway. Not sure what I would have done had I needed to specify the port number.
As new to Oracle I struggled a few days finding solution to this
this article helped me alot
As of Oracle 21 c
This is my Connection string for C#
Password=dev;Persist Security Info=True;User ID=Dev;Data Source=localhost:1521/XEPDB1
Keep in mind Dev is Username which is also the Schema name for Oracle

Connecting C# app with Oracle 10g: ORA-12154: TNS:could not resolve the connect identifier specified

I am a beginner in working with databases. I am trying to access Oracle10g database from a c# application. But when I do so i get this error:
ORA-12154: TNS:could not resolve the connect identifier specified"
I'm using the following code:
string oradb = "Data Source=ORCL;User Id=system;Password=goodbye;";
OracleConnection conn = new OracleConnection(oradb); // C#
conn.Open();
Is there an error in the connection string oradb?
Start the Visual Studio, open View menu + Server Explorer.
Right mouse click on Data Connection + Add Connection + Select Oracle Database
server Name : localhost or name of your machine, set username & password and click on Test Connection to verify the above parameters. Press OK if test is succeeds.
From properties windows you can obtain connection String and it should be look a like:
Data Source=localhost;Persist Security Info=True;User ID=scott;Password=***********;Unicode=True
Oracle is just stating that it can't find the database.
If you're running a local Express Edition database, you should be able to just use XE as an instance name, and everything should already be set up, otherwise you can most easily add it to tnsnames.ora.
To find the correct tnsnames.ora to change, you can try (from the command prompt)
tnsping ORCL
That will tell you which files Oracle is using to try to find the database. If tnsping is an unknown command, you may have to search for it and go to the correct place before running it.
One you found the correct tnsnames.ora, you need to add the instance ORCL to it. There should be an existing file with examples, the syntax of that file is too complex to answer here, if you need help, Oracle has quite extensive documentation.
This is a very common oracle error. Simply put, it means that you have named the database you wish to be connected to and Oracle doesn’t know who the heck you’re talking about. I suggest 6 Steps to fix ORA-12154:
Check instance name has been entered correctly in tnsnames.ora.
There should be no control characters at the end of the instance or database name.
All paranthesis around the TNS entry should be properly terminated
Domain name entry in sqlnet.ora should not be conflicting with full database name.
If problem still persists, try to re-create TNS entry in tnsnames.ora.
At last you may add new entries using the SQL*Net Easy configuration utility.
More informations on oracle site or here : http://turfybot.free.fr/oracle/11g/errors/ORA-12154.html

Connect to a SQL Server database on another network via asp.net and c#

I have a customer database that is kept on a SQL Server on our local network. I would like to create a customer portal that will be on our website that is hosted through another company. How would I connect to that SQL Server database?
Give the website host access rights to the sql server. Assuming Sql Server 2008; go to your management studio and right click the server (root) in the object explorer window and go to properties. You can manage permissions from there. Also, it will show you the "server" to use in your connection string (something like [server]\SQLEXPRESS, which can be used locally and remotely).
Create a proper connection string in the website, preferably in web.config, to use for all of your connections to the database. You can then get this connection string from, say, your data layer via
ConfigurationManager.ConnectionStrings["ConnString_Name"].ConnectionString;
Aside from the correct connection string, you will also need to ensure that the website can communicate with your SQL Server. If you have firewalls, you'll need to configure ports if they are blocked.
The alternative is to create a web service that is hosted on a DMZ zone that will communicate with your sql server internally. The website (hosted by the third party) would communicate via this web service to get the data (you can setup authentication so only those with rights can use this web service). By going this route, you're not exposing your internal sql server directly.
This answer is based on some assumptions because question does not provide all the required information.
For this you need to set ConnectionString property for your connection object.
For example
Data Source=yourIP;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;
Here is MSDN link connectionStrings
This is a example of SQLExpress connectionstring in Web.Config
<connectionStrings>
<add
name="LocalSqlServer"
connectionString="data source=.\SQLEXPRESS;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;"
providerName="System.Data.SqlClient"
/>
</connectionStrings>
There is a Beginners guide on Code Project which is voted 5, it will give you all you need to get started.
But before you start working with the code, I suggest that you first test the connection with SQL Server management studio. make sure that you can connect and query some data, otherwise you may face some more confusion while trying to pull this off with code only at the first time.
To connect to SQL Server from C#.NET, you need to create a connection string such as below:
private SqlConnection connection; private string connectionString = #"Server=(local);Database=Embedding_SQL_Test;User ID=sa;Password=123"; connection = new SqlConnection( connectionString );
Next, you use the SqlConnection object created above to create a 'SqlCommand', as shown below:
SqlCommand cmd = new SqlCommand( "select * from Customer where CustomerID = #Cid", connection);
The SQL query shown here can be replaced by a SELECT, INSERT, UPDATE queries etc.
Next to execute the SQL queries in the database, you use the following methods: ExecuteReader - to execute SELECT queries ExecuteNonQuery - to execute INSERT, DELETE, UPDATE, and SET statements.
This is a very short description of how to connect to SQL Server database from C# and execute SQL queries in the database. For details about the connection string, the methods and their parameters check the following link: ( http://www.shahriarnk.com/Shahriar-N-K-Research-Embedding-SQL-in-C-Sharp-Java.html ) Here you will also find details about how to pass parameters to the SQL queries as well as calling stored procedures and much more.

Migrating from SQL Server CE to SQL Server database

Currently I am using SQL Server CE for persisting my data for which I am providing with a .sdf and connection string mentioned in app.config pointing to this .sdf file.
Now I want to provide user with the flexibility to have the data stored in their own SQL Server database if present at there disposal.
Now I am facing the problem of how to change the connection string at runtime if user chooses to uses its own database ?
Or if restrict them to use my predefined .mdf file how to attach that in their SQL Server ?
My recommendation would be to have 2 connection strings in the configuration file (app or web). There is a special section for them intuitively called ConnectionStrings. You can then switch between them based on other settings.
Changing connection strings dynamically is actually pretty easy to do as long as you have a place to store the new settings (ie. web or app config files). If you provide a way for them to enter the server information you can use the ConfigurationManager class to update your app/web.config.
Ado.net typically has parameters on almost any db connection object that allows you to specify the connection string as an arguement. Additionally, there are helper classes that can be used to construct the connection string on the fly like the SqlConnectionStringBuilder or EntityConnectionStringBuilder. I personally love the Entity Framework as it allows you to create the database from the model itself if it does not already exist, provided you already have the connection string.

How to connect an existing strongly-typed data set to a different server at run time?

I am coding a simple space empire management game in Visual C# 2008, which relies on connecting to a remote SQL server database to get/store data.
I would like the user to be able to connect to a user-specified SQL server from the login screen(he specifies IP address, port, database name, ID, password and presses "connect" button). However, I found out that the Dataset connection string property is read only and cannot be changed. Is there any way to guide the wizard-generated DataSet to a user-specified server at run time?
I believe that if you go into the project settings and change the connection string setting type from "Connection String" to "string" and change the scope from "Application" to "User", the connection still works and it becomes an editable string at runtime.
Please back up your source code before trying this.

Categories

Resources