Click here to Skip to main content
16,020,345 members
Home / Discussions / Database
   

Database

 
GeneralRe: complilation error on stored procedure using sql??????????????? Pin
ZurdoDev9-Mar-17 10:16
professionalZurdoDev9-Mar-17 10:16 
GeneralRe: complilation error on stored procedure using sql??????????????? Pin
LOKENDRA YADAV9-Mar-17 10:23
LOKENDRA YADAV9-Mar-17 10:23 
GeneralRe: complilation error on stored procedure using sql??????????????? Pin
LOKENDRA YADAV9-Mar-17 10:15
LOKENDRA YADAV9-Mar-17 10:15 
GeneralRe: complilation error on stored procedure using sql??????????????? Pin
ZurdoDev9-Mar-17 10:18
professionalZurdoDev9-Mar-17 10:18 
QuestionSQL Pin
Member 111616257-Mar-17 16:34
Member 111616257-Mar-17 16:34 
AnswerRe: SQL Pin
Richard MacCutchan7-Mar-17 23:11
mveRichard MacCutchan7-Mar-17 23:11 
AnswerRe: SQL Pin
ZurdoDev9-Mar-17 9:56
professionalZurdoDev9-Mar-17 9:56 
QuestionHow to create SQL server 2016 localdb using C# code? Pin
w142435-Mar-17 20:47
w142435-Mar-17 20:47 
SQL Server 2016 LocalDB installed, and instance 'FFw1a' is created and running:

C:\Program Files\Microsoft SQL Server\130\Tools\Binn>sqllocaldb i Ffw1a
Name: FFw1a
Version: 13.0.2151.0
Share name:
Owner: MinKyung\icey.dong
Auto Create: No
Status: Running
Start Time: 2017/3/3 16:48:38
Pipe name: np:\\.\pipe\LOCALDB#E10BE0E6\tsql\query

I want to create a local db file by below C# code:

private void CreateDatabase()
{
System.Data.SqlClient.SqlConnection tmpConn;
string sqlCreateDBQuery;
tmpConn = new SqlConnection();

tmpConn.ConnectionString = @"Data Source=(LocalDB)\FFw1a;AttachDbFilename='D:\y\2\TestDB_Data.mdf'; Integrated Security=True;Connect Timeout=30;Encrypt=False";

sqlCreateDBQuery = "CREATE DATABASE TestDB ON PRIMARY "+
@"(NAME = TestDB_Data, FILENAME = 'D:\y\2\TestDB_Data.mdf', SIZE = 2MB, FILEGROWTH = 10%) "+
@"LOG ON (NAME = TestDB_Log, FILENAME = 'D:\y\2\TestDB_Log.ldf', SIZE = 1MB, FILEGROWTH = 10%)";

SqlCommand myCommand = new SqlCommand(sqlCreateDBQuery, tmpConn);
try
{
tmpConn.Open();
myCommand.ExecuteNonQuery();

MessageBox.Show("Database has been created successfully!", "Create Database", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (System.Exception ex)
{
MessageBox.Show(ex.ToString(), "Create Database", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
finally
{
tmpConn.Close();
}
return;
}

But it cause exception on 'tmpConn.Open()', and the message is:
An attempt to attach an auto-named database for file D:\y\2\TestDB_Data.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

How can I change the connection string and sqlCreateDBQuery to create a database file successfully?

AnswerRe: How to create SQL server 2016 localdb using C# code? Pin
Chris Quinn5-Mar-17 23:28
Chris Quinn5-Mar-17 23:28 
GeneralRe: How to create SQL server 2016 localdb using C# code? Pin
w142437-Mar-17 22:14
w142437-Mar-17 22:14 
GeneralRe: How to create SQL server 2016 localdb using C# code? Pin
kosmas kafataridis18-Apr-17 1:22
kosmas kafataridis18-Apr-17 1:22 
Questionhow to connect table from database to table from another database? Pin
salm abdullsamad4-Mar-17 6:17
salm abdullsamad4-Mar-17 6:17 
AnswerRe: how to connect table from database to table from another database? Pin
Michael_Davies4-Mar-17 6:57
Michael_Davies4-Mar-17 6:57 
QuestionFinding status of which Jobs ran successfully and which are failed on daily basis Pin
indian1432-Mar-17 8:38
indian1432-Mar-17 8:38 
AnswerRe: Finding status of which Jobs ran successfully and which are failed on daily basis Pin
Afzaal Ahmad Zeeshan2-Mar-17 9:09
professionalAfzaal Ahmad Zeeshan2-Mar-17 9:09 
QuestionHow to sync two or more collocation database server? Pin
Gilbert Consellado1-Mar-17 17:59
professionalGilbert Consellado1-Mar-17 17:59 
AnswerRe: How to sync two or more collocation database server? Pin
Eddy Vluggen6-Mar-17 2:56
professionalEddy Vluggen6-Mar-17 2:56 
GeneralRe: How to sync two or more collocation database server? Pin
Gilbert Consellado7-Mar-17 1:58
professionalGilbert Consellado7-Mar-17 1:58 
QuestionFoxpro DBF, Joining a table with multiple columns that can return more than 1 record and projecting it into a list(Of Pin
jkirkerx27-Feb-17 8:07
professionaljkirkerx27-Feb-17 8:07 
Questionintegration of flash to javadb Pin
Member 1302448026-Feb-17 19:38
Member 1302448026-Feb-17 19:38 
AnswerRe: integration of flash to javadb Pin
Mycroft Holmes26-Feb-17 21:53
professionalMycroft Holmes26-Feb-17 21:53 
GeneralRe: integration of flash to javadb Pin
Richard Deeming26-Feb-17 23:43
mveRichard Deeming26-Feb-17 23:43 
QuestionGetting data Pin
Member 1302296325-Feb-17 0:23
Member 1302296325-Feb-17 0:23 
AnswerRe: Getting data Pin
Richard MacCutchan25-Feb-17 20:48
mveRichard MacCutchan25-Feb-17 20:48 
Questionc# to call MySQL Update Stored Proc error Pin
jonmy24-Feb-17 0:00
jonmy24-Feb-17 0:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.