How can I configure ScrewTurn Wiki to use SQL Server? - sql-server

I'm trying to configure the excellent ScrewTurn Wiki product on my server, and haven't been able to make sense of the documentation.
I'd like to configure it to use SQL Server for storage. Do I still need to specify a valid value for the PublicDirectory key in web.config?
This is how I've tried to configure the connection so far, but obviously I'm missing something else:
<add name="WikiData"
connectionString="Data Source=xxx;Initial Catalog=xxx;User ID=xxx;Password=xxx"
providerName="System.Data.SqlClient"/>
I can't even get the page to load without complaining about the PublicDirectory key after adding this connection string. Before I added the connection string, the site came up fine without SQL Server implementation. I'm not even getting a chance to see if the DB connection works and don't know what to name it here, if the name makes any difference in the key.
How can I get this working properly?

figured it out, did not see the connection string section. resolved.

Related

Azure Function Database Connection

I have a Python package that I am able to run successfully on an Azure Data Science Virtual Machine. However, when I push it to Azure as a Function, I cannot successfully make a database connection. I was getting an error that the ODBC Driver 13 for SQL Server was not supported, so I changed the driver to ODBC Driver 17 for SQL Server and now I am NOT getting an error, but no data is being returned for a query that I know should return data.
Is there any other reason that data would not be returned? Firewall issues? do I need to add a binding? Do I need to separate out the connection string to feed each part (e.g., Driver, UID, PWD) into pyodbc.connect() separately? Right now I am feeding it in like this:
setting = os.environ("CONNECTIONSTRING")
conn = pyodbc.connect(setting)
This query works fine returning data when I run it on the VM using this code, just not as a Function.
(Note, this is different from my previous post regarding reading the Azure App Setting. That problem has been solved).
There are many parts where this could be breaking.
I'd suggest start by having a Profiler or Extended Events trace on your SQL Server to verify whether a connection is even being established. If not then you need to work through the the various points of connectivity to find out where it breaks. The identity, firewall, NSGs etc might all come into play here.
Once you see a connection then you can play with permissions to ensure that your query then returns your data.
Without a full picture of your infrastructure and settings it is hard to pin it down further.
Turns out it was not a database connectivity issue like I thought it was; it was a code error.

Reasons for "The network path was not found" in ASP.NET MVC

I made ASP.NET MVC web application, uploaded the files, also the database, but I get the following error when browsing it.
The network path was not found
I'm using Entity Framework and this is the connection string in my web.config file
<connectionStrings>
<add name="[mydatabase]Entities" connectionString="metadata=res://*/Models.Model1.csdl|res://*/Models.Model1.ssdl|res://*/Models.Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=sql.[somedomain].net;initial catalog=[mydatabase name];User ID=[myUsername];Password=[myPassword];MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
I've uploaded many websites using IP Address eg. xxx.xxx.x.xxx as data source, but this is the first time to use server name eg. sql.[somedomain].net -I cannot get the server ip-, so I'm not sure if this caused the error, or if I should make something special to make it work.
So, I'm asking if there is something I should do to use server name as data source, if not then what else may cause this error.
This answer doesn't really help.
Thanks in advance.
Update
If I ping the server sql.[somedomain].net, I get this result
Ping request could not find host sql.[somedomain].net. Please check the name and try again.
And if I nslookup it, I get this result
*** Unknown can't find sql.[somedomain].net: Non-existent domain
So does that mean -for sure- that the server is not accessible. And is there anything I can do beside contacting the hosting technical support?
Solved
It was the Hosting Provider error/misconfiguration. After 3 days of searching and contacting the customer support, they realized it was their issue. I'm leaving this question to tell future viewers to Host Only with reliable/well-known Hosting Providers no matter what.
The info you got from tech support seems fairly contradictory. It's common to disable remote access for database servers, but if that's the case, then using the domain to connect doesn't really help you.
If you're trying to connect to this database from a published MVC project, residing with the same provider as supplies your database, then you should have no issues connecting as you're no longer "remote". However, unless your DNS is also hosted at the same provider, using the domain may make the connection appear remote, as it's going outside to come back in. The safest bet is to simply use the IP address of the database server in the connection string.
Also, pay attention to the IP address you have for the database server. If it's in the 10.* or 172.* range, it's a local IP, but if it's something else, it's most likely an outside IP address. Trying to connect to such an address, may also make the connection appear remote as you're going outside the network to come back in. Also, while disallowing remote access to a database server is a good idea, you can generally safely allow remote access to certain IPs. You most likely don't have control over that directly, but you can check with your provider to see if they can add an explicit rule for your web server's IP so that even if the connection is coming through as remote, it'll still work.
As far as working locally in development, you'll just have to use a local database. You may already have that covered, but your question wasn't entirely clear on that aspect.
I also faced the same issue. I used the forward slash instead of back slash for instance name (clustername\instancename). Once I changed it to back slash. It worked fine.

Azure: The context is being used in Code First mode with code that was generated from an EDMX

I have MVC app running fine in local. After updating to Azure, it started throwing the error:
The context is being used in Code First mode with code that was generated from an EDMX file for either Database First or Model First development. This will not work correctly. To fix this problem do not remove the line of code that throws this exception. If you wish to use Database First or Model First, then make sure that the Entity Framework connection string is included in the app.config or web.config of the start-up project.
I have checked if there is any difference between the local web.config and azure web.config. except the credentials, everything is same. And it read:
<add name="DBEntities"
connectionString="metadata=res://*/DBModel.csdl|res://*/DBModel.ssdl|res://*/DBModel.msl;
provider=System.Data.SqlClient;
provider connection string="data source=xx;initial catalog=xx;persist security info=True;user id=xx;password=xx;MultipleActiveResultSets=True;application name=EntityFramework""
providerName="System.Data.EntityClient" />
I am using EF 6.1.3, MVC5
I ran into the same error message and managed to solve it with the help of this post here on StackOverflow.
In the Azure Management / Web Apps / [Your web app] / CONFIGURE / connection strings , make sure of 3 things :
The connection string has the same name as the connection string in your project.
The connection string Value contains all of the metadata as appears in the connection string in your project. Mine looks like this:
metadata=res://\*/Models.[MyModel].csdl|res://\*/Models.[MyModel].ssdl|res://\*/Models.[MyModel].msl;provider=System.Data.SqlClient;provider connection string="Server=tcp:[myDBServer].database.windows.net,1433;Database=[myDB];User ID=[myDBUser]#[myDBServer];Password=[myPassword];Trusted_Connection=False;Encrypt=True;Connection Timeout=30;"
The third column (default set to SQL Database) is set to Custom
Found a simpler solution than adding all the stuff in the Azure connection string. I just changed the connection string name in Azure. It worked..
I had to deal with the same issue. The solution was
Connect to the website by FTP
Edit web.config
Add following connection string:
add name="NewDatabaseEntities" connectionString="metadata=res:///NewDatabase.csdl|res:///NewDatabase.ssdl|res://*/NewDatabase.msl;provider=System.Data.SqlClient;provider connection string="Data Source=tcp:your.database.windows.net,1433;initial catalog=your;integrated security=False;User Id=your;Password=your;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient"
Thanks Microsoft for poorly documentation of EntityFramework Database First on Azure.
You need to change this line metadata=res:///NewDatabase.csdl|res:///NewDatabase.ssdl|res://*/NewDatabase.msl;
to
metadata=res://*/;

My code against LocalDB works but I can't see the database anywhere

I have a simple website that uses EF Code First and LocalDB. This is in my web.config:
<connectionStrings>
<add name="MyContext" providerName="System.Data.SqlClient" connectionString="Server=(localdb)\v11.0;Integrated Security=true;"/>
</connectionStrings>
My website works fine, PowerShell commands like Update-Database and Add-Migration work fine, however, I cannot see the database anywhere inside Visual Studio. Not in SQL Server Object Explorer, not in Server Explorer (when I try to connect to "MyContext" database on the (localdb)\v11 server, the dialog tells me that there is no such db there).
I am confused. Where is my database?
There is one property define - Initial Catalog
Data Source=(localdb)\v11.0;Initial Catalog=YourDbName;Integrated Security=True;
You need to specify the name of the database within your connection string, like this:
Server=(localdb)\v11.0;Database=YourDbName;Integrated Security=SSPI;
or, in the more typical format (since it's the format generated by SqlConnectionStringBuilder):
Data Source=(localdb)\v11.0;Initial Catalog=YourDbName;Integrated Security=True;
It's worth noting for seasoned developers that the use of "SSPI" is encouraged :
When false, User ID and Password are specified in the connection. When true, the current Windows account credentials are used for authentication.
Recognized values are true, false, yes, no, and sspi (strongly recommended), which is equivalent to true.
And also that the Connection String docs on MSDN are quite exhaustive if you're wondering what keys are valid for all providers, and also which keys are valid for the SqlClient provider.

Connection String trouble

This isn't so much a programming issue, but i'm not sure where else to get this level of expertise.
In any case, the issue i'm having is getting a legacy application to run locally on my machine. it connects to a SQL server using this connection string
Provider=SQLOLEDB.1;Persist Security Info=False;User ID=UN;password=PW;Initial Catalog=DB;Data Source=IP
(where of course UN, PW, DB and IP are different, real, values)
I've changed it to this, to connect to a SQL Server Express instance on my local box:
Data Source=MY-PC-NAME\SQLEXPRESS;Initial Catalog=DB;Integrated Security=True
The app errors out with a generic cannot connect type error, which isn't helpful in the least bit.
Anyone have any advice? I don't have much more information on this blasted program ..
Try something like:
Provider=SQLNCLI10;Server=Server\SQLExpress;Database=myDataBase;Uid=myUsername; Pwd=myPassword;
VB6 used OLEDB syntax; your previous syntax was for .NET
This eventually worked Provider=SQLOLEDB.1;Persist Security Info=False;User ID=;password=;Initial Catalog=;Data Source=mypcname\SQLEXPRESS;Integrated Security=SSPI
I have no idea why. I needed to specify the integrated security.
Thanks for your help!

Resources