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
 Development Tools
 ASP.NET
 How to create a table

Author  Topic 

earlmoore
Starting Member

6 Posts

Posted - 2007-04-09 : 06:31:46
Hi
I am trying to create a table via an asp.net 2 page.... but having a little difficulty
My background is php but my employers do not support php. therefore i have had to start learning ASP.NET

I have a database etc. and what i need
I am using Visual Web Developer which is on my personal laptop, (again my employers do not support it) other wise i would have installed in on my work pc.

Basically I cannot create or do not know how to create a table in an ASP.NET page. have scanned a few books and googled it but no joy

Can anyone help

Many thanks in advance

Tunes...Make you dance more easily

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-04-09 : 06:46:20
Either you can use Table control from HTML tab in toolbox or you can do it manually using <TABLE> tag (I assume you mean HTML table here)

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

earlmoore
Starting Member

6 Posts

Posted - 2007-04-09 : 07:07:04
No not the html side, the database table.
have a database, and want to create a table in it but am completely lost

Tunes...Make you dance more easily
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-04-09 : 07:15:39
I don't think that is proper way of creating table but you can do it by executing CREATE TABLE command through SqlCommand object.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

earlmoore
Starting Member

6 Posts

Posted - 2007-04-09 : 07:24:15
I have tried this
<body>
<form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ebm_ConnectionString %>"
SelectCommand="SELECT * FROM [test_table]">
</asp:SqlDataSource>

</div>
</form>
</body>


Tunes...Make you dance more easily
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-04-09 : 07:35:45
I am not sure what you want exactly? Is [test_table] already created in the database or you want to create it?

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

earlmoore
Starting Member

6 Posts

Posted - 2007-04-09 : 07:39:25
Duh Sorry
me being stupid
<body>
<form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ebm_ConnectionString %>"
SelectCommand="CREATE TABLE test_table ( test1 INT PRIMARY KEY, test2 VARCHAR() NOT NULL)">
</asp:SqlDataSource>

</div>
</form>
</body>


Tunes...Make you dance more easily
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-04-09 : 10:13:04
Your application should just about NEVER be creating tables in your database. Why are you trying to do this? What is your goal? It is usually a horrible, horrible idea to have your application code dynamically create and tables and indicates a bad database design (or none at all)... tables and their columns and relations should be CONSTANTS that you design once, not dynamic and changing.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

earlmoore
Starting Member

6 Posts

Posted - 2007-04-09 : 10:33:41
I just want a table in my database
At the moment there isnt one.
I cannot create one via a webtool, so i assume the only other way is to create one with a ASP.NET page and sql

Tunes...Make you dance more easily
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-04-09 : 10:35:47
You are working with a database but you have no client tools that will let you connect to it? Enterprise manager, Query Analyzer, SQL Management Studio, Visual Studio -- you don't have any of these?

SQL Mangagement Studio Express can be downloaded for free:
http://www.microsoft.com/downloads/details.aspx?FamilyId=C243A5AE-4BD1-4E3D-94B8-5A0F62BF7796&DisplayLang=en




- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-04-09 : 10:50:36
or at the very least, you can use sqlcmd tool if you are working with SQL Express.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

earlmoore
Starting Member

6 Posts

Posted - 2007-04-09 : 17:35:09
thats excellent!

many many many thanks

just goes to show how new i am

again many thanks it worked


Tunes...Make you dance more easily
Go to Top of Page
   

- Advertisement -