I'm getting the error below while starting the storage emulator. By mistake I deleted the mdf and log files in users/admin folder. It's holding reference someplace and not allowing me to create the DB again. Please help me.
Added reservation for 127.0.0.1:10000/ in user account RaviBorra-PC\Ravi Borra.
Added reservation for 127.0.0.1:10001/ in user account RaviBorra-PC\Ravi Borra.
Added reservation for 127.0.0.1:10002/ in user account RaviBorra-PC\Ravi Borra.
Found SQL Instance (localdb)\v11.0.
Creating database DevelopmentStorageDb201206 on SQL instance '(localdb)\v11.0'.
Cannot create database 'DevelopmentStorageDb201206' : Database 'DevelopmentStorageDb201206' already exists. Choose a different database name..
One or more initialization actions have failed. Resolve these errors before attempting to run the storage emulator again. Please refer to http://go.microsoft.com/fwlink/?LinkID=248088 for more details.
Thank you,
Ravi Krishna B.
Do these steps:
Open cmd.exe (Command Prompt)
Write this:
SqlLocalDb stop "v11.0"
SqlLocalDb delete "v11.0"
and press Enter
Note that "v11.0" is MyInstance.
For more details, visit this link.
This problem may occur if you delete the data file C:\Users\<Username>\DevelopmentStorageDb201206.mdf but do not delete the corresponding database on the LocalDB server instance. One possible solution is:
Connect to the (localdb)\v11.0 instance from SQL Server Management Studio.
Delete the DevelopmentStorageDb201206 database. There will be the error message that the database deletion ended with an error. Ignore this message and refresh the database list manually.
Now you can start the Azure Storage Emulator.
This is not a problem related with Azure components rather LocalDB instance is reporting back to Azure request that DB still exist. Check LocalDB instances in your machine using "sqllocaldb i" first and the delete the instance using "sqllocaldb d 'instance_name'". I could not test it in my machine but this may unblock you if localdb instance is blocking you.
In Windows Azure SDK 1.7, Windows Azure Storage Emulator uses LocalDB instance specific configuration at following location:
%LocalAppData%\DevelopmentStorage\DevelopmentStorage.201206.config
And based on that you will see that v11.0 instance is Windows Azure Storage Emulator specific so verify if that is running and deleting it will let DSInit to create the DB again in LocalDB.
If you have Sql Express installed on your local box then (localdb)\v11.0 is most likely not your local Sql instance. It is more likely {MyComputerName}\SQLEXPRESS.
Going to:
C:\Users\<yourloginname>\AppData\Local\DevelopmentStorage\DevelopmentStorage.201206.config
And changing:
<SQLInstance>(localdb)\v11.0</SQLInstance>
To:
<SQLInstance>{MyComputerName}\SQLEXPRESS</SQLInstance>
solved this error for me.
I hope this helps..
If you already tried and failed perform:
SQLLocalDB stop v11.0
SQLLocalDB delete v11.0
Delete all the files in C:\Users\<accontname>\WAStorageEmulatorDb* (usually one mdf and one ldf)
Create a new account (I called it Azure, with administrative rights)
Run again the installation
Installation completed!
For me this works... I had tried to format the PC before use this way. I supposte my problem is related to my username that contains "invalid" characters like Name 'NickName' Surname while the "Azure" account seems to be OK for him.
I figure it out 'cause somewhere in the log I have a property destination path set to "C:\Users\Name$_" that is far away for the path of my user account folder.
After that you can go on CMD.exe and prompt:
control userpasswords2
From the control you can delete the Azure login without delete the file folders!
Hope it helps!
I simply deleted all the mdf's and ldf's in C:\Users\accountname\ that started with DevelopmentStorage... or WAStorageEmulator.
Re-ran the install and it worked.
This can also be caused by the folder not existing for localDB. It looks like Visual Studio / Azure will not automatically create containing folders. I just copied the path from the error code into explorer and created the directory up to the .MDF file.
In visual studio go to Tools -> Options -> Database Tools-> Data connections and change a localdb instance name from v11.0 to some other name.
I did have SQL Express installed, as Brian Ogden suggested in his answer, but I wanted to try & point Azure Storage Emulator to my SQL Express instance without modifying configuration files.
I did this by running the initialization process for Storage Emulator & passing my server\instance details for SQL Express using the available switches. Below example of the command I executed (from an elevated command prompt):
AzureStorageEmulator.exe init -server MY-PC-NAME -instance MYSQLINST
This created the database successfully (in my SQL Express instance) & got my Storage Emulator working.
I am using a named instance, but I'm thinking this same approach can be used for default instances by omitting the -instance switch.
Related
I am creating a POS system in Windows Forms (C#) in which I use a SQL Server database file (.mdf) to store items (completely offline). When I install the application on my computer, it works fine, but when I install it on my clients PC, an error happens:
(provider: SQL Network Interfaces, error: 52 - Unable to locate a Local Database Runtime installation"
I read somewhere that the problem is caused due to the fact that the connection string of the database of my client's PC is different. I tried to add the connection string dynamically on runtime but again it only worked on my computer.
Another reason that might be causing the problem is that I used 'server-based database' since local database option isn't available in Visual Studio 2017 for some reason.
Another solution I looked up stated that I should install SQL Server Express on my client's PC. That also failed (maybe I have to set it up in a way or something).
I also tried adding the database.mdf and database_log files in the setup folder.
Lastly I tried installing 3rd party installers (Advanced installers 15.8 and InstallShield Wizard in VS 2015) which also failed.
(I have provided the code for the connection of database taking place and the connection string)
public void ConnectToDB()
{
DBConnection = new SqlConnection(#"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename=C:\Users\SAIM NASSER\Desktop\app layer\data layer\Database1.mdf; Integrated Security = True");
DBConnection.Open();
ResultSet = new DataSet();
}
If I understand you correct, you want to use LocalDB
That means using Sql Server without installing a full sql server, but just the localdb part from sql server express.
For this to work you need to install the LocalDB Driver, which can be found here
https://www.microsoft.com/en-us/download/details.aspx?id=29062
You need only the ENU\x64\SqlLocalDB.MSI
This is the only thing you need to install in your clients computer, I believe it can also be installed silent, you have to research a bit for that.
And yes, you also should change the connection string on the clients computer, you need to alter it so it points to the MDF file on the clients computer, because that location will probably be different then on your computer
EDIT
To get the connection string working, you can try this
On the clients computer, create a text file and rename the extension to .udl
So for example you have a file test.udl
Now from explorer, double click it, this will open the datalink editor.
From here you can enter/choose different settings, and click on the test connection button.
Once you get a working connection, save it, and open this file with notepad.
Inside you will find the working connection string
Hope this helps
I'm currently working on a ASP.net website, I have everything working and wanted to deploy it to the server which is goDaddy to test the changes I made. I have had this code, the exact same project with the identical database connection string and calls on the server before. Nothing changed really I just changed one method in a class which has nothing to do with the database at all. I have the code trust set to full so the code should have permission to connect. When I set the code trust lower then full it will give me an error that I don't have the needed permissions so I'm sure this isn't where the problem lays.
Like the title says when I try the code on my local environement everything works just fine. When I try to do the same thing on the server I get a message saying:
"unable to connect to any of the specified MySQL hosts"
when you go to http://test.ceremoniecompleet.nl/admin and try to log in you will get the error. When I try to login locally it works just fine.
The connection string I'm using is as follows
con.ConnectionString = "server=188.121.44.188; database=CeremonieCompleet_DB; uid=CCU; pwd=mypassword;";
I've tried to use 188.121.44.188:3306 but this doesn't work at all. One of the godaddy support people suggested using this but this just fails on both locally and the server.
does anyone have any clue what could be going on?
the only thing that changed really is that I used visual studio 2012 before and now I'm using visual studio 2015 because my pc needed a completely fresh install.
EDIT:
Currently the mysql.data.dll that I added to the project is version 6.0.3.0 could it be that this just needs an upgrade?
The 188.121.44.188 is the godaddy server?
If it is, try changing to 'localhost'.
If it isn't, try to create a database in godaddy and set the server to 'localhost'.
To set the port, you need this string "server=<>; port=3306; ..."
I've been attempting to create a table through my machine's Azure storage emulator. I can recreate the problem with a very simple program that uses only WindowsAzure.Storage nuget version 6.2.0 :
using Microsoft.WindowsAzure.Storage;
namespace StorageEmulatorTest
{
internal class Program
{
private static void Main(string[] args)
{
var cloudStorageAccount = CloudStorageAccount.Parse("UseDevelopmentStorage=true");
var cloudTableClient = cloudStorageAccount.CreateCloudTableClient();
cloudTableClient.GetTableReference("JohnnyTest").CreateIfNotExists();
}
}
}
After 25 seconds, this will throw an exception of type Microsoft.WindowsAzure.Storage.StorageException with only this message:
The remote server returned an error: (500) Internal Server Error.
I have attempted:
Ensuring my WindowsAzure.Storage nuget package is the latest version (6.2.0).
Re-installing the Azure SDK for VS2015 2.8.1 (and ensuring that it's the latest version)
Stopping, clearing, initing the Azure Storage Emulator through the Azure Storage Emulator command line tool (seemed to work fine, no errors)
Reading the web response's stream through the exception's ".InnerException.Response.GetResponseStream()". This fails with an exception that states "Stream was not readable".
Restarting my machine (desperation kicked in)
My bag of tricks is running low. Has anybody encountered this issue?
I solved it. I had to completely wipe out my existing local storage emulation instance. Using "AzureStorageEmulator.exe clear" or "AzureStorageEmulator.exe init" was insufficient. Even uninstalling the Azure SDK was insufficient.
I started by stopping the storage emulation:
AzureStorageEmulator.exe stop
AzureStorageEmulator.exe clear
AzureStorageEmulator.exe init /forceCreate
That last command errored and indicated that it could not create the database.
Then I deleted (actually, I renamed them) these remaining files that comprised the database behind the azure storage emulator:
C:\Users\[Me]\AzureStorageEmulatorDb42_log.ldf
C:\Users\[Me]\AzureStorageEmulatorDb42_log.mdf
Finally, I started the emulator back up
AzureStorageEmulator.exe init /forceCreate
AzureStorageEmulator.exe start
Success!
I'm unsure what got me into the situation, but my best guess is that this was caused by a recent upgrade of the Azure SDK.
I think in many cases Johnny's answer will solve the issue.
In my case this also did not work, because AzStorageEmulator did not create the database AzureStorageEmulator510 (database instance (localdb)\MSSQLLocalDB) and also not the tables within.
So I used SSMS to create database AzureStorageEmulator510 from scratch,
then I found that an older version AzureStorageEmulator57 was still on my PC, so I attached it (you can find the databases in C:\Users\YOURACCOUNT) - extracted the database structure to a SQL script and ran it for AzureStorageEmulator510.
After that, I started the emulator and created a new blob container using AzStorageExplorer.
The Error 500 seemed to occur because that database (and structure inside) was missing and could not be recreated by the CLI command AzureStorageEmulator.exe init /forceCreate.
Other things you can check (possible issues):
It can also be AzStorageEmulator can't access its database. One of the reasons (and how it can be fixed) is described here.
After installing a newer version of the instance (localdb)\MSSQLLocalDB, it can be that the related database is not attached. This will result in a strange error like
Cannot open database "AzureStorageEmulator510" requested by the login. The login failed. Login failed for user 'YOURACCOUNT'.
If that is the case, you can fix it by simply connecting to localDb via SSMS, then attach the database: Right-click on databases, select Attach... in the context menu, then in the dialog, add the database file (located in C:\Users\YOURACCOUNT).
I have a huge problem and I don't even know what to check.
I have a big SSIS package which at beginning it runs an "Execute Script" task (named ST_2275f0b3eced4c84bd35d4c826cab866.csproj), wrote in C#, which looks like this:
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using Microsoft.Win32;
namespace ST_2275f0b3eced4c84bd35d4c826cab866.csproj
{
[System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
public void Main()
{
Dts.Variables["user_uca"].Value = Registry.LocalMachine.OpenSubKey(#"SOFTWARE\TDCredentials").GetValue("user_uca").ToString();
Dts.TaskResult = (int)ScriptResults.Success;
}
}
}
Bottom line is that it loads a SSIS package variable with the data from a specific Windows Registry key.
The issue is that when I ran the SSIS package from Visual Studio it works. But when I ran the Sql Agent Job which was made for that SSIS package, it gives me the error:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object. at ST_2275f0b3eced4c84bd35d4c826cab866.csproj.ScriptMain.Main()
This error means that the Windows Registry key does not exists. Because if I deleted on purpose the specific Windows Registry key and then ran the SSIS package from Visual Studio, I get the exact error message.
I have checked all that I could thing of: the sql server and the host having those Windows Registry key - they are the same. Also i gave permissions for "Everyone" for those keys, also I had put the key in HKLocalMachine, in order to be sure they exist for all the users, still same error.
Any hints?!
Thanks in advance, Bogdan.
The problem is ultimately a permissions issue. Either that the service account that runs SQL Agent or the Credentials you are running the subsystem jobs step of SSIS does not have the ability to read that part of the registry.
You need to either grant that user access or create a delegate that can read from the registry.
As a side note, you don't have to use your Script approach. Reading Registry values and assigning them to Variables is native functionality in SSIS. See Configurations for more information on the topic. You will still have to deal with the permission issue but then you won't have code copy and pasted throughout your packages.
As said, it was a permission issue for the account which was running the sql agent job.
Therefore the solution was first to make a new credential, from "Credentials" -> "New Credential". In the "Identity" field I choose an user with sysadmin rights (eg. john.doe). In the field "Credential name" I had filled "John". Then from Sql Server Agent -> Proxies -> SSIS Package Execution I created "New Proxy". I filled at "Proxy name" a name (ProxyJohn), at "Credential name" I choose the credential defined early, "John", then at field "Active to the following subsystems" I have checked the "Sql Server Integration Services Package" option.
Then, at my Sql Server Agent -> Jobs, on my job (which gave me the error message when ran), in proprieties -> Steps-> "Run As" I have choose the new credential created above, named "ProxyJohn" instead of "Sql Server Agent Service Account" (which was by default)
It worked like a charm.
Hope it will help.
Best regards, Bogdan
I want to make a database backup with this C# code:
connect = new SqlConnection(con);
connect.Open();
// Execute SQL
SqlCommand command = new SqlCommand
(
#"backup database MY_database to disk='d:\SQLBackup\wcBackUp1.bak' with init, stats=10",
connect
);
command.ExecuteNonQuery();
connect.Close();
When I run it, the following error message shows up:
Cannot open backup device 'd:\SQLBackup\wcBackUp1.bak'.
Operating system error 3(The system cannot find the path specified.).
If I change the path to d:\wcBackUp1.bak it seems to be ok, is without error, but the file does not exist, it was not generated.
If I run in SQL the command I have the message that it was 100% processed, but I didn`t see the file.
Could someone help me please?
Make sure the location "d:\SQLBackup\" exist in your database server and not on your client machine.
Two things to check.
The Sql Service may not have access to the d:\sqlbackup folder. Old Sql installs used to default to install the service with full access to the machine, but newer instances tighten that up. You could try changing the path to the directory where the default backups are stored.
Secondly, if the sql server is not on the same machine that you are running this program, then you must remember that the D: will be the D: on the sql server and not your local machine
Fundamentally, the Windows account that the SQL Server service runs under must have write permissions on the specified folder.
You can check what account this is by looking in SQL Server Configuration Manager, under SQL Server Services (look at the Log On As column)
Check what permissions that account actually has on the target folder using Explorer -> right click folder -> properties -> security -> advanced -> effective permissions.
One way to check that this is the problem is to change your code to back up to your SQL instance's backup folder, where the permissions are likely to be correct. For example
C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Backup