473,796 Members | 2,573 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to create sql server database file from VB6 application

2 New Member
Using SQL Server 2005 Express.

I want to create and maintain the SQL database and tables from within a VB6 application. First I need to create an empty database file. This I can't do.

Using
Set mcn = New ADODB.Connectio n
mcn.Open mstrConnectStri ng

I have tried various connection strings -
mstrConnectStri ng="server=(loc al)\SQLEXPRESS; " & "integrated security=sspi;d atabase=;"

mstrConnectStri ng="Data Source=.\SQLEXP RESS;AttachDbFi lename=" & "xxx.mdf" & ";Integrate d Security=True;C onnect Timeout=30;User Instance=True"
Dec 29 '09 #1
4 9228
debasisdas
8,127 Recognized Expert Expert
Connection string is used to used to connect to an existing database not to create a new one.
Dec 30 '09 #2
vb5prgrmr
305 Recognized Expert Contributor
First, you need to have Administrative Rights to the database engine ("SA"). This includes read, write, create, delete. Then, you do not connect to any particular database but if you must connect to a database then connect to the MASTER database. Then you will need to execute a CREATE DATABASE statement, followed by CREATE TABLE statements...

http://msdn.microsoft.com/en-us/library/ms176061.aspx

Use the pane on the left to navigate to the CREATE TABLE statement, and you may want to look at the CREATE INDEX and CREATE PROCEDURE if you are wanting to create stored procedures.

So, you process would go like this...

Connect to MASTER
CREATE DATABASE
USE DATABASE_NAME 'to switch to the database you just created
CREATE TABLE
CREATE INDEX
CREATE PROCEDURE
then if you are wanting to insert data into the database, use the INSERT STATEMENT or if you have created a stored procedure us it...



Good Luck
Dec 30 '09 #3
MartinJackson
2 New Member
My problem is to get connected so I can create my SS db from the VB6 application.

The answer I needed was how to connect so I could run the SQL create DB.
Your answer is Database=Master ;
The rest is -

ConnectionStrin g = "Provider=SQLNC LI;Server=YourS erverName;Datab ase=Master;Inte grated Security=SSPI;"

Many thanks
Dec 30 '09 #4
vb5prgrmr
305 Recognized Expert Contributor
Yes, just be careful to not make any changes to the MASTER database because if you do, you could ruin the entire installation or DBMS...



Good Luck
Dec 30 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

8
2152
by: Jonas L | last post by:
I'm creating a application that should handle contacts, orders etc. I want to distribute only the exe file and let the application take care of creating and changing the database that is to be used. Furthermore, I would also like to make it possible for the user to select which sort of database to create and use, MSSQL, Oracel, Access etc. Is this possible? Or do I have distribute a databas file as well? My first idea was to use OLEDB...
3
2160
by: NWx | last post by:
Hi, I write an ASP,NET application who uses SQL Server (MSDE) as Back-end I'm an experienced developer, but haven't used SQL server before and I need some help. Since I don't have full SQL server (but only MSDE), I don't have Enterprise manager. So I used Access XP (using an ADP file) to create the database on MSDE server (tables, views, stored procs etc)
4
23734
by: AlexDP | last post by:
My program has to access an SQL Server DB file that is in the same folder as the executable. i dont want to setup a server. i was able to do this on my own computer, the program would access any sql server db file without it being attached to the server. When i take it to another system it fails to run. All systems have SQL Server Express and SQL Server 2005 installed. Can someone please direct me through the steps to fix this problem? ...
1
13654
by: orenbt78 | last post by:
Hi, I am trying to: 1. Create a SQL database (I am working with SQL 2005 Express) 2. with a C# code 3. when the user is not the computer administrator. I have managed to create the database file (code below). I am not sure it is the right way. Can you take a look please?
1
5925
by: Mrozik | last post by:
Hi! I have Web Application with forms authentication. Data and security model resides in Oracle database. I have 'login' page with MS 'Login' control. In my LoggingIn event for debug purposes I have only: FormsAuthentication.RedirectFromLoginPage( "testlogin', false); (all users are authenticated) It works fine till now - I have still error:
5
5140
by: Savante | last post by:
I am trying to investigate the JET databases to enable me to save data from a datalogging program I'm writing. At the moment, I've been using tutorial 21 of the SAMS "Learn it in 24 hours book". Whilst the book has been useful in terms of adding and editing records from an already existing database file, I want to be able to make my own database file at runtime. My databasing program can create an unknown number of columns and I...
10
2610
by: AAaron123 | last post by:
I want to create a database with one table on the host. I can't user SQL Server Management Studio to do it so I guess I have to do it programmatically. I have in mind that in the session start (or maybe application start would be better) I'd check to see it the database exists and if not create it. The problem is that I have no idea how to do that.
0
1632
by: KishorDhembare | last post by:
Hi Everybady I Want To Create New Database When My Application Starts First Time My Application Developed In Vb.net I Get The Error When I Run Command which I Have Command Is Like. Dim file As FileInfo = New FileInfo(Path.GetFullPath("TextFile1.txt")) Dim backupScript As String = file.OpenText.ReadToEnd() Dim strCommand As String = backupScript
9
6619
by: santhanalakshmi | last post by:
Hi, I am trying to open database file(.mdf) using enterprise manager. Right Click on Databases -> All Tasks -> Attach database I am browsing the .mdf file from my local drive and finally clicking OK It shows me an error. Please help me out.Thanks in advance. I cant able to find out
0
9530
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10459
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10182
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10017
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9055
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6793
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5445
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.