Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > BOOK: Beginning ASP.NET 2.0 and Databases
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 2.0 and Databases
This is the forum to discuss the Wrox book Beginning ASP.NET 2.0 and Databases by John Kauffman, Bradley Millington; ISBN: 9780471781349
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 2.0 and Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 6th, 2009, 08:15 AM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
Location: london, , United Kingdom.
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
Default Ho can i name the database dynamicly

Hi I need to create a database that takes the name from the textbox so far i have this one
Code:
Dim conn AsNew SqlConnection(ConfigurationManager.ConnectionStrings("test").ConnectionString)
conn.Open()
 
Dim Cmd AsNew SqlCommand("Create Table TestTable(ID Int,Name Varchar(50))", conn)
Cmd.CommandType = CommandType.Text
Cmd.ExecuteNonQuery()
conn.Close()
this will create a table called TestTable i need to change the TextTable Dynamicly depending on woat is in the text box


thanks
__________________
bx
  #2 (permalink)  
Old January 6th, 2009, 10:38 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Well which do you need to do: create a database or create a table?

In any event you would want to do something like this:

vb Code:
Dim Cmd AsNew SqlCommand("Create Table " & textbox1.Text & " (ID Int,Name Varchar(50))", conn)


Obviously by doing things this way you open yourself up all sorts of SQL Injection attacks so sanitize accordingly.

hth.
-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
The Following User Says Thank You to dparsons For This Useful Post:
bex (January 6th, 2009)
  #3 (permalink)  
Old January 6th, 2009, 11:56 AM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
Location: london, , United Kingdom.
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
Default

I Need to create tables The controll is going to be used only by the administrator is that still a potential security risk?
one more thing How can i insert a value into the table?
something like this
Code:
 

Dim Cmd AsNew SqlCommand("Create Table " & textbox1.Text & " (ID Int,Name Varchar(50))", Insert Into " & textbox1.text & "),conn)
__________________
bx
  #4 (permalink)  
Old January 6th, 2009, 12:04 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Any time you are working with Dynamic SQL there is the potential that something will go wrong, regardless if the only people using the tool are administrators!

If you want to continue using the same methodology that you are currently using I would probably do something like this:

vb Code:
Dim SQL as String
SQL = "CREATE TABLE " & textbox1.Text & " (ID Int,Name Varchar(50));"
SQL += "INSERT INTO " & textbox1.Text & "(ID, Name) VALUES(1, 'Name');"

Dim Cmd AsNew SqlCommand(SQL, conn)

What exactly are you doing that requires this type of functionality?

hth
-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
  #5 (permalink)  
Old January 6th, 2009, 12:24 PM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
Location: london, , United Kingdom.
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
Default

I was asked by my employer to build a project that he needed to create new tables from the browser and then assign to the users so they can retrive the data from those tables depending on what was assignet to them by the administrator.

Next thing i am going to ask you is gonna be how to assign spesific tables to spesific users
__________________
bx
  #6 (permalink)  
Old January 6th, 2009, 12:33 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Hmmm. There is a myriad of ways to assign permissions to tables, how you do it is going to be up to you but this sounds like the making of a management nightmare. Since there is a 1:1 correlation between users and tables, you will have to create a table for every single user and, depending on how many potential users you have, the management of said tables becomes unwieldy. I would probably use a single database table for all users and then filter the data coming out of said table based on a given user.

I can not honestly think of a good secnario where I would want each website user to have their own single table in my database.

hth.
-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
  #7 (permalink)  
Old January 6th, 2009, 01:25 PM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
Location: london, , United Kingdom.
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
Default

yes i do agree but this is an intranet application whith max user 20 so the users are employees,what he wants is when an employee logs in he/she would see a costumised page pulling data from those tables the administrator will create.
__________________
bx
  #8 (permalink)  
Old January 6th, 2009, 01:46 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Why not use a single table? It would be more effecient and less of a management nightmare. Plus, it would be much easier to do it that way then to try and maintain that X user has rights to Y table.
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
  #9 (permalink)  
Old January 13th, 2009, 08:36 AM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
Location: london, , United Kingdom.
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
Default

Hi i need to search the entier DatabaseFor spesific Column name and pull the data into a listbox.
__________________
bx
  #10 (permalink)  
Old February 3rd, 2009, 12:04 PM
Registered User
 
Join Date: Feb 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Smile Question

how to connect VB with Access via odbc?
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamicly filling drop down JAdkins Classic ASP Basics 4 June 26th, 2007 09:54 AM
Ho do we store pictures in a database? vitalis PHP Databases 2 March 18th, 2007 12:05 PM
Adding controls dynamicly Paula222 Access VBA 21 February 9th, 2006 05:29 AM
Ho to do nested if statements scoobie PHP How-To 2 April 24th, 2005 06:22 AM
dynamicly name a record set mat41 Classic ASP Professional 6 March 16th, 2004 03:50 AM



All times are GMT -4. The time now is 05:33 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.