Copy table from one data connection and paste into database in another data connection in visual studio - asp.net

This may be super obvious, but I can't see it. I have a table I created in SQL Server Management Studio. I had to create it there because I needed to use a function for an alpha-numeric ID column that increments itself. I then exported the table, but had to use my local server. Now, in visual studio, I have the local server connection that contains the table I want to copy to a connection for a remote server. I can right-click and select 'Copy', but I can't right-click and 'Paste' into the database I need.
I'm fairly new at this and if anyone has a better way to make an auto incrementing alpha-numeric column in Visual Studio, I would love to hear about it.
Thanks

I would go back into SQL Server Management Studio, connect to the remote server, and create the table there. This would also show you any possible permissions issues that you may have on the remote server.

You will need to update your app.config file in your VB Project.
You can right click on the project and click properties
Under 'Settings' you will find a 'Connection' with a 'Name' and a 'Value'
You need to change the value for 'Connection Properties' for:
Server Name: from LOCALHOST to your remote server url
Also be sure to update username/password credentials
Click 'Test Connection' to confirm you can connect
You can also manually edit these settings in the app.config file
You can also manually edit the MyApp.exe.config file where your app is deployed (where MyApp is the executable name)

Related

Having trouble linking to my Azure DB

I'm publishing an ASP.NET MVC 5 app to Azure Websites. In my Azure portal, I linked the website to my Azure SQL database. However, when I click the "View Connection String" link on the portal, I get a popup that says there are no connection strings.
Please keep in mind that my connection string in my app have a different name i.e. it's not named DefaultConnection, rather it's named myAppNameConnection.
Also, I'm publishing the app directly from VS 2013 and I'm able to select the correct DB in the publish wizard. However, when the app is published it is NOT able to communicate with the database. Any idea what may be causing this issue?
In your VS tool you have the right connection string configured in your Web.config file.
When you publish the website in Azure, it overwrites automatically the connection strings in the web.config file with the ones stored as global variables in the website service.
You must go on the Azure portal, click on your website, then click on configure on the tab menu.
Go down to connection strings, and insert the right connection string there.

The configuration option 'user instances enabled' does not exist?

I'm using SQL Server 2008 R2 for Window 8
When I built my webpage, sql server suddently stop and show an error :"Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed. "
Try to fix that problem by searching google. As recommended, I have to delete the folder C:\Users\User\AppData\Local\Microsoft\Microsoft SQL Server Data, but there is no folder with that path
Try another way,I run the below code in SQL Query window:
exec sp_configure 'user instances enabled', 1.
Go
Reconfigure
But it has an error: The configuration option 'user instances enabled' does not exist, or it may be an advanced option.
Help!!! Which way is the better one??? And How can I fix this:Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.
You can try this:
Stop all user instance processes of SQL Server running under your local account (open up task manager and look for sqlsrv.exe process and end it)
Delete all files in the %LOCALAPPDATA%\Microsoft\Microsoft SQL Server Data\SQLEXPRESS folder
All be aware that if you are using XP the location will be something like
C:\Documents and Settings\\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data\SQLEXPRESS
F5 again
The problem is known issue. SQL Express cannot create a user instance using the set of engine files in your local app data folder, deleting them should allow sql server to recreate them with the correct credentials for you to F5 successfully.
I believe you may not be having SQLExpress installed as directories does not exist. In that case you will need to reinstall the version of SQL Express that was included in the project.

Visual Studio error when trying to find my database

I am a student learning asp.net and I ran into a problem when trying to reconfigure data sources I created. When I run my web application I am able to edit/add/delete entries that are in my database but when I try to create or reconfigure a datasource it gives me this message:
Database schema could not be retrieved for this connection. Please
make sure the connection settings are correct and that the database is
online.
Could not load file or assembly
‘Microsoft.SqlServer.Management.Sdk.Sfc, Version=10.0.0.0, Culture=
neutral, PublicKey Token=89845dcd8080cc91’ or one of its
dependencies. The system cannot find the file specified.
Now I never changed the place of the database on my computer and I have never deleted it from the originating folder. I went into my 'Sever Explorer' tab and it shows that the database is connected. I right clicked on my database in the data connections list and went to 'Modify Connection...' and ran the 'Test Connection' option and it says the "Test connection succeeded". If my application can edit the database why can't Microsoft Visual Studio find the connection to let me edit the datasource?
As the error indicated that the problem was the system cannot locate the right assembly (SQL Server SDK).
I suspect that the installation of your SQL Server is not a complete or a successful one, or you should have to download some components to provide a successful connection.
Useful links with components that you would consider downloading here or here

How to include database schema and data in setup and deployment of asp.net web application?

I am trying to deploy my web application created with asp.net in visual studio 2010. I have successfully created .exe and .msi file, install it and run using IIS Manager. However, it needs a database which is why it is returning
System.Data.SqlClient.SqlException: The SELECT permission was denied on the object 'TableName', database 'master', schema 'dbo'.
whenerver I try to run it on browser with localhost.
How do I include my database file in deployment so that when I install my application in another computer, the database will also be created?
It is not at all clear what exactly you mean by database file but if you are referring to an SQLLite or SQL Server CE database file all you have to do is go to properties and change the "Copy to Output Directory" property to "Copy if Newer" (don't forget to do the same with the required class libraries).
If you are referring to SQL Server, Oracle or some other RDBMS database than you can't just copy the file, you'd have to either use DDL to create the database or attach the database file using the SSMS.
EDIT: I did not pay attention to the exception you posted so the second part of my question is relevant. SQL Server database file cannot be just copied to another computer, the target computer must have the SQL Server installed and you must detach the file from your local SQL Server and attach it on the remote SQL Server using the SQL Server Management Studio.

asp.net SQL Database File Error

We're getting the following error when trying to establish a connection to a database file in the project:
Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.
Any ideas on how we can fix it?
Thanks in advance!
http://jeremywadsworth.com/Default.aspx?blogentryid=56 has one possible fix.
http://forums.asp.net/t/1377174.aspx also has further discussion on the topic.
Hope that helps.
--
One more idea. I think I've encountered something like this when using Visual studio to create and access my database. You can detach your database file from visual studio and then directly attach it to your SQL server. I can't remember if the problem manifested in the same way or not but this should get you around the user instance issue. If this doesn't apply let me know and I'll see if i can come up with anything else.
If you are using IIS as the server,then this occurs because the server takes default asp.net database.
In IIS server,create your own application pool and run your app on that instead of using the default pool.
Check the permissions.Give full access control rights.
Also,
go to SQL server configuration>properties. Select local system in the built-in app.. And your new pool should also have local system selected.
This fixed the problem for me. Hope it works for someone here.
PS: If you are trying to making connectivity in Visual studio for android application,then close the visual studio before running it on android as the process wont complete if visual studio is open and will result into error.
SQL Express file attach starts a new 'user instance' SQL Server. This involves a new master/model/msdb/tempdb set of files that are created in the user settings data folder. also the startup of the new 'user instance' can take up to several minutes on extreme cases.
This MSDN article on SQL Server 2005 Express Edition User Instances cover in detail the process and luckly it has some Common Issues and fixes. The most common failure is due to access rights over the user settings copied files. You will usualy get details about the failure in your NT event log (ie. why did the child instance not start).
We got over this by copying the database from my machine to my team-mate's.

Resources