Connect to SQL

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2008
Posts: 324
Reputation: sonia sardana has a little shameless behaviour in the past 
Solved Threads: 7
sonia sardana sonia sardana is offline Offline
Posting Whiz

Connect to SQL

 
-1
  #1
Jun 29th, 2009
hey frnds, tell me one thing as in VB.Net suppose if we want to connnect to SQL,then in form coding itself.We create the database,Create table ...& insert values...

WE do that cz if we run the project at Client side,even if no database is there our project automatically creates it So that no error is there,Is it also possible in ASP.net...

Is yes,can somebody tell me from where to start...
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 130
Reputation: stevenpetersen is an unknown quantity at this point 
Solved Threads: 1
stevenpetersen's Avatar
stevenpetersen stevenpetersen is offline Offline
Junior Poster

Re: Connect to SQL

 
-2
  #2
Jun 29th, 2009
Tell me if this helps.....
  1. <script languae="PHP">
  2. open_database("location","username","password");
  3. display_page("PAGE_ID");
  4. close_database();
  5. </script>
Last edited by peter_budo; Jun 30th, 2009 at 2:09 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Steven Petersen
Web Designer / Web Master
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 66
Reputation: reach_yousuf is an unknown quantity at this point 
Solved Threads: 12
reach_yousuf reach_yousuf is offline Offline
Junior Poster in Training

Re: Connect to SQL

 
0
  #3
Jun 30th, 2009
Hi

This is not a recommended solution... it's not a good programming practice... the maintenance would be a big issue as you move in development stage.

Try keep n-tier architecture.
1) keep db as separate with ur scripts
2) Dataaccess layer
3) business layer
4) presentation layer
Yousuf
Software Developer
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 88
Reputation: IdanS is an unknown quantity at this point 
Solved Threads: 12
IdanS IdanS is offline Offline
Junior Poster in Training

Re: Connect to SQL

 
0
  #4
Jun 30th, 2009
Hi,

Read this to how to create the DB on runtime:
http://www.codeproject.com/KB/database/CreateDB.aspx
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 164
Reputation: dnanetwork has a little shameless behaviour in the past 
Solved Threads: 24
dnanetwork's Avatar
dnanetwork dnanetwork is offline Offline
Junior Poster

Re: Connect to SQL

 
0
  #5
Jun 30th, 2009
hi it's me again...i was little curious about u r sql server version...? is it 2000/2005/2008?
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,215
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 572
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: Connect to SQL

 
0
  #6
Jun 30th, 2009
This will create a table named "Test123"
  1. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  2. Dim conn As SqlClient.SqlConnection = New SqlClient.SqlConnection("Data Source=APEX2006SQL;Initial Catalog=ServManLeather;Integrated Security=True")
  3. conn.Open()
  4. Dim cmd As SqlClient.SqlCommand = New SqlClient.SqlCommand("Create Table Test123 ( someColumn varchar(123) )", conn)
  5. cmd.ExecuteNonQuery()
  6. cmd.Dispose()
  7. conn.Close()
  8. conn.Dispose()
  9. End Sub
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC