943,763 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 684
  • ASP.NET RSS
Jun 29th, 2009
-1

Connect to SQL

Expand Post »
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...
Similar Threads
Reputation Points: 0
Solved Threads: 8
Posting Whiz
sonia sardana is offline Offline
326 posts
since Mar 2008
Jun 29th, 2009
-2

Re: Connect to SQL

Tell me if this helps.....
ASP.NET Syntax (Toggle Plain Text)
  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.
Reputation Points: 45
Solved Threads: 1
Junior Poster
stevenpetersen is offline Offline
132 posts
since Jun 2009
Jun 30th, 2009
0

Re: Connect to SQL

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
Reputation Points: 12
Solved Threads: 38
Junior Poster
reach_yousuf is offline Offline
194 posts
since Sep 2007
Jun 30th, 2009
0

Re: Connect to SQL

Hi,

Read this to how to create the DB on runtime:
http://www.codeproject.com/KB/database/CreateDB.aspx
Reputation Points: 22
Solved Threads: 13
Junior Poster in Training
IdanS is offline Offline
96 posts
since Jun 2009
Jun 30th, 2009
0

Re: Connect to SQL

hi it's me again...i was little curious about u r sql server version...? is it 2000/2005/2008?
Reputation Points: 28
Solved Threads: 106
Banned
dnanetwork is offline Offline
633 posts
since May 2008
Jun 30th, 2009
0

Re: Connect to SQL

This will create a table named "Test123"
vb.net Syntax (Toggle Plain Text)
  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
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: asp net connectionstring
Next Thread in ASP.NET Forum Timeline: Double quotes inside string variable. e.g " my name is "jaikit" and what is "





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC