Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 very urgent question

Author  Topic 

nounabarbie
Starting Member

10 Posts

Posted - 2006-02-18 : 14:12:07
Hi
I am using SQL server for the first time.
I found SQL server books online hard to understand,so I want to ask 2 questions:
First,how can I create a table,in fact I want to create a database containing 2 tables.
Second,I have a visual basic form in which I enter data.Upon
pressing the "send" button,I want to be able to send my data entries to an SQL server table.
When I want to send data entries from Vb form to an access table, I use the following code:
Dim rstablename As ADODB.Recordset
Set rstablename = New ADODB.Recordset
rstablename.Open "tablename", cnnTest, adOpenStatic, adLockOptimistic, adCmdTable

rstablename.AddNew


rstablename![field1] = txtname1.text
rstablename![field2] = txtname2.text
...

rsArticle.Update

rsArticle.Close

What's the difference if instead using an access database,I am using SQL server database
Could you give me the detailed steps to do my 2 tasks?
thanks in advance

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2006-02-18 : 14:22:26
Access is a file database, which means its supports a few to hundreds of cuncurrent users, while MSSQL is an enterprise database management system, which can support thousands and millions of users.

regarding your requests, i would advice you go for a training in databases and VB, for books see this link
http://www.sqlteam.com/store.asp

There are two ways to create a database and tables, either in Query analyzer or Enterprise manager. See books online or buy a book

Afrika

Oh, by the way Welcome to SQLTeam
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2006-02-18 : 14:54:51
Here is some basic T-Sql code to show how to create a database, table, stored procedure, and execute the stored procedure. You can execute all this code in a Query Analyzer window. Definately keep with trying to get used to Books Online, it will be your best resource. As far as the application code to make calls to your database, I'd suggest first things first. Get the Sql side working. After that you can post some specific questions in the developer's forum or the Asp.net forum.

use master
go
Create Database myNewDatabase
go

use myNewDatabase
go
---------------------------------------------------------
--create a table (CREATE TABLE in Books Online)
if object_id('myNewTable1') > 0
drop table myNewTable1
go

create table myNewTable1
(myNewTable1ID int identity(1,1) primary key
,i int not null
,createDate datetime not null
,updateDate datetime null)
go

----------------------------------------------------------
--create a storte procedure to insert data to myNewTable1 (CREATE PROCEDURE in Books Online)
if object_id('myNewTable1_ins') > 0
drop procedure myNewTable1_ins
go

create procedure mynewTable1_ins
@i int
as

insert myNewTable1 (i, createDate)
values (@i, getdate())

go
----------------------------------------------------------

exec myNewTable1_ins @i = 10
exec myNewTable1_ins @i = -2

select myNewTable1ID
,i
,createDate
,updateDate
from myNewTable1

go

use master
drop database myNewDatabase


Be One with the Optimizer
TG
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-02-19 : 03:34:17
Have you got Enterprise Manager installed? (It comes with SQL Server 2000)

If so open up your database, right click to create a new table, and then in the Table Designer type in the column names you want, choose the datatype (and size when appropriate)

Its advisable to use the "door key" button to mark the Primary Key column(s) - they are the one(s) which will uniquely identify the record.

If you have been using Access you should find that route pretty similar to Access.

Kristen
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-02-20 : 00:44:09
Also make use of Query Analyser to test your queries

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -