SQL Server connectionStringName needed WebSecurity - sql-server

I'm really sorry but I think I can't figure out a very trivial thing. I am trying to get started with WebSecurity (asp.net MVC), but the initial method asks for a connection string.
I have a SQL Server 2012 edition installed.
Created a database "Users"
Where can I find the connection string?
(I did manage to create a database + tables using EF code first, so I know things are installed properly)

You'll need to get the specifics (userid, password and servername) for your install, but this website can help with the syntax/format:
http://www.connectionstrings.com/sql-server-2012

Related

Database and Dataset data is empty [duplicate]

Apparently, using AttachDbFilename and user instance in your connection string is a bad way to connect to a DB. I'm using SQL server express on my local machine and it all seems to work fine. But what's the proper way to connect to SQL server then?
Thanks for your explanation.
Using User Instance means that SQL Server is creating a special copy of that database file for use by your program. If you have two different programs using that same connection string, they get two entirely different copies of the database. This leads to a lot of confusion, as people will test updating data with their program, then connect to a different copy of their database in Management Studio, and complain that their update isn't working. This sends them through a flawed series of wild goose chase steps trying to troubleshoot the wrong problem.
This article goes into more depth about how to use this feature, but heed the very first note: the User Instance feature has been deprecated. In SQL Server 2012, the preferred alternatives are (in this order, IMHO):
Create or attach your database to a real instance of SQL Server. Your connection string will then just need to specify the instance name, the database name, and credentials. There will be no mixup as Management Studio, Visual Studio and your program(s) will all be connecting to a single copy of the database.
Use a container for local development. Here's a great starter video by Anna Hoffman and Anthony Nocentino, and I have some other resources here, here, and here. If you're on an M1 Mac, you won't be able to use a full-blown SQL Server instance, but you can use Azure SQL Edge if you can get by with most SQL Server functionality (the omissions are enumerated here).
Use SqlLocalDb for local development. I believe I pointed you to this article yesterday: "Getting Started with SQL Server 2012 Express LocalDB."
Use SQL Server Compact. I like this option the least because the functionality and syntax is not the same - so it's not necessarily going to provide you with all the functionality you're ultimately going to want to deploy. Compact Edition is also deprecated, so there's that.
Of course if you are using a version < SQL Server 2012, SqlLocalDb is not an option - so you should be creating a real database and using that consistently. I only mention the Compact option for completeness - I think that can be almost as bad an idea as using AttachDbFileName.
EDIT: I've blogged about this here:
Bad Habits : Using AttachDBFileName
In case someone had the problem.
When attaching the database with a connection string containing AttachDBFile
with SQLEXPRESS, I noticed this connection was exclusive to the ASP.NET application that was using the database. The connection did block the access to all other processes on the file level when made with System.Data.SqlClient as provider.
In order to assure the connection to be shareable with other processes
instead use DataBase to specify the database name in your connection string
Example or connection string :
Data Source=.\SQLEXPRESS;DataBase=PlaCliGen;User ID=XXX;password=ZZZ; Connect Timeout=30
,where PlaCliGen is the name (or logical name) by which SQLEXPRESS server knows the database.
By connecting to the data base with AttachDBFile giving the path to the .mdf file
(namely : replacing DataBase = PlacliGen by AttachDBFile = c:\vs\placligen\app_data\placligen.mdf) the File was connected exclusively and no other process could connect to the database.

SQL Server connection failing with LinqToSQL but working with EF 6

I have an application (.NET WPF LinqtoSQL) that works when I connect to a local database. When I changed to a database on a different server I get an error (SQL Server Instance not found error 26).
The solutions to this error are all based on the server, firewall, and making sure SQL Server Browser is up and running, none of which I can do because I have no rights on the server.
But I created a small test application using WPF and EF (ADO.NET) that successfully connects to the exact same database (and table). I have no clue what might be going on, but I am not sure I want to re-write the application using EF (at least right now).
Does anyone understand the difference between the framesworks' connection method to point me to a possible solution for the LinqToSQL version beyond waiting for the IT guys to "fix" the server?
Given the revelation above that EF and L2S use the same connection class I figured a new project that points to the new server would fix my issue. And it did:
I created a new project, added a new L2S item, and then copied in all of my old projects views/ viewmodels/ etc. and it runs just fine.
I thought I could simply update the connection string, as this is what I believe I have done successfully in the past, but perhaps there is something else had to be set somewhere in the project settings or generated DataContext code to the new server. If anyone knows what that is please answer and I'll accept it.

Connecting to sql database

(I am a sql noob and I just can not figure this out on my own)
For some time now I have been trying to establish a connection to a SQL database in codename one but to no avail. First I tried connecting to a MariaDB database from one.com. All that's needed for the connection is
Database db = Display.getInstance().openOrCreate("databaseName");
if I am not mistaken, but I am guessing this implies that I have somehow already established a connection to the database. This is not the case however so it creates a new .sql file, right? I can recall that you can connect to a database in the services tab in Netbeans. I chose the MySQL(Connector/ J Driver) which should work with MariaDB, or should it? I entered all my data and i says that it can not establish connection to the database.
the error i get
So I thought I might as well try using localhost. I used XAMPP to host a database and connected in the netbeans services tab.
connected?
Now testing was needed to see if this works. I started the SQL journey with this https://www.codenameone.com/manual/files-storage-networking.html#_sql and integrated the part after "You can probably integrate this code into your app as a debugging tool". I changed database name to "mybase" (it's existance can be confirmed in picture 2). Ran the app, opened the dialog, entered "select ID from customers" and got: java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (no such table: customers) It does not get past the first call to "executeQuery". The customers table definitely exists so what am I missing to establish connection?
I really need instructions to connect to the localhost database and ideally also to the one hosted by my webhost provider.
Thanks,
Jona
The Database class is to access the SQLite DB on the mobile device. To connect to external databases, you'd have to do something different, such as a ConnectionRequest or Socket I think.

Implementing container based security in tomcat using sql server 2005

I have been trying to implement container based security in tomcat 6.0 using sql server 2005. It worked fine using tomcat-user.xml file, but when i change the realm to sql server it throws an error. I have gone through almost everything on google, but no help. Can anybody please guide me to some sure shot path that will help me fix this problem. This is what my realm looks like
<Realm
className="org.apache.catalina.realm.JDBCRealm"
debug="99"
driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
connectionURL="jdbc:sqlserver://mindfield-pc:1138;databaseName=College;user=sa;password=sa;SelectMethod=Cursor"
connectionName="sa"
connectionPassword="sa" digest="SHA"
userTable="Users" userNameCol="username"
userCredCol="password"
userRoleTable="Roles" roleNameCol="rolename"/>
I have checked that my sql server accepts sa username and password and NT Authority has been added to the security users. Any help would be highly appreciated.
Realm definition is really case-sensitive so make sure all values are in the correct case.
Good Luck!

Creating SQL Server database without the /MSSQLSERVER in the connection string?

I found this pretty weird thing when I first installed SQL Server 2008, for some reason there are two things that I want to get rid of and I can't:
If my computer name is, say, ABC, then I always have to connect to ABC/MSSQLSERVER for the server name when I log in from the SQL Server client, instead of using just using ABC, may I know how I can do that?
How can I default the DB so that if I have multiple DB on the server (System DB + my real DB), I can always default to use my real DB without saying "Use MyRealDB" every time?
Thanks a lot!
Regards,
Anyi
1) When installing, you picked a named instance.
2) In user admin, you can specify the default database per user.
What's happened here is that your SQL Server is installed as a named instance. To remedy this, you'll have to remove and reinstall SQL Server.

Resources