|
-
Feb 27th, 2007, 04:56 PM
#1
Thread Starter
Member
building an SQLServer database
I need to know how to connect to data in a database I create incode, in SQLServer. Does anyone know what I need in order to set the connection in runtime with the new database name?
(I didn't mean to post duplicate threads, it happend because I sent my post when I weren't near the computer about mor then 15 minutes, and then you get the chance to write your user and passward again - what made me think my thread wasn't there. I didn't know it was there already.)
Last edited by SuKaSa; Mar 1st, 2007 at 01:21 AM.
-
Feb 27th, 2007, 05:25 PM
#2
Re: change name of connection to SQLServer on runtime
To connect to any SQL Server database you need to assign the appropriate values to the ConnectionString property of an SqlConnection object. www.connectionstrings.com has the appropriate formats. If you want to build a connection string piece by then, assuming that you're using VB 2005, the easiest way is with an SqlConnectionStringBuilder.
-
Mar 1st, 2007, 01:30 AM
#3
Thread Starter
Member
Re: building an SQLServer database
I did that before I even read your reply, and it works, thanks.
Now I'm searching for a way to build relations between tables, this time in SQLServer. I've googled and so far had no luck.
-
Mar 1st, 2007, 01:39 AM
#4
Re: building an SQLServer database
You create relations when you create the child table by specifying a constraint.
http://msdn2.microsoft.com/en-us/library/ms174979.aspx
I'd assume you can do an ALTER TABLE too after the fact but I've never done so.
-
Mar 4th, 2007, 01:17 AM
#5
Thread Starter
Member
Re: building an SQLServer database
Thank you very much, I think this is what I'm looking for.
-
Mar 8th, 2007, 03:24 AM
#6
Thread Starter
Member
Re: building an SQLServer database
Look, I've tried using your link, and here's my query after trying:
CREATE TABLE tbl_A({A_ID NUMBER CONSTRAINT fk_tbIA_tbIE_id (FOREIGN
KEY REFERENCES tbl_E(E_ID) ON DELETE CASCADE ON UPDATE CASCADE), name char(1)} )
CREATE TABLE tbl_E( { E_ID NUMBER, name char(1) } )
It haas syntax errors. can you see them? I bet it refers to the parentheses.
-
Mar 8th, 2007, 08:11 AM
#7
Re: building an SQLServer database
You must create TBLE first - right?
Also - get into Management Studio and put in that DDL statement - it will help you see you syntax errors better.
Why are you creating a table from code?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|