Click here to Skip to main content
15,899,679 members
Home / Discussions / Database
   

Database

 
GeneralRe: GETTING EXCEPTION ON JDBC TRANSACTION MGMT --->java.sql.SQLException: Invalid column index:at LINE 8 & 12 Pin
Richard MacCutchan10-Mar-17 22:27
mveRichard MacCutchan10-Mar-17 22:27 
QuestionAccess Application VS .Net Application Access Behind - How to Decide Pin
Member 1304435510-Mar-17 15:52
Member 1304435510-Mar-17 15:52 
AnswerRe: Access Application VS .Net Application Access Behind - How to Decide Pin
Mycroft Holmes11-Mar-17 13:05
professionalMycroft Holmes11-Mar-17 13:05 
GeneralRe: Access Application VS .Net Application Access Behind - How to Decide Pin
Member 1304435511-Mar-17 14:54
Member 1304435511-Mar-17 14:54 
GeneralRe: Access Application VS .Net Application Access Behind - How to Decide Pin
Mycroft Holmes12-Mar-17 14:31
professionalMycroft Holmes12-Mar-17 14:31 
QuestionFailed Steps of all Jobs and Disabled steps of all Jobs Pin
indian14310-Mar-17 6:30
indian14310-Mar-17 6:30 
AnswerRe: Failed Steps of all Jobs and Disabled steps of all Jobs Pin
ZurdoDev10-Mar-17 7:13
professionalZurdoDev10-Mar-17 7:13 
GeneralRe: Failed Steps of all Jobs and Disabled steps of all Jobs Pin
indian14327-Mar-17 11:04
indian14327-Mar-17 11:04 
Questioncomplilation error on stored procedure using sql??????????????? Pin
Member 130474308-Mar-17 19:48
Member 130474308-Mar-17 19:48 
QuestionRe: complilation error on stored procedure using sql??????????????? Pin
Richard MacCutchan8-Mar-17 21:24
mveRichard MacCutchan8-Mar-17 21:24 
Rant[REPOST] complilation error on stored procedure using sql??????????????? Pin
Richard Deeming9-Mar-17 1:20
mveRichard Deeming9-Mar-17 1:20 
AnswerRe: complilation error on stored procedure using sql??????????????? Pin
ZurdoDev9-Mar-17 2:02
professionalZurdoDev9-Mar-17 2:02 
AnswerRe: complilation error on stored procedure using sql??????????????? Pin
ZurdoDev9-Mar-17 9:47
professionalZurdoDev9-Mar-17 9:47 
GeneralRe: complilation error on stored procedure using sql??????????????? Pin
LOKENDRA YADAV9-Mar-17 10:12
LOKENDRA YADAV9-Mar-17 10:12 
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 

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.