WinHost
    Login
  •  
    English (en)
    • English (en)
  • WinHost Support Portal
  • Knowledge Base

    Find answers to common questions

  • Forum

    WinHost community forum

  • Blog

    WinHost blog

  • Google +

    WinHost Google + Page

  • Twitter

    WinHost Twitter feed

  • Facebook

    WinHost Facebook page

Article Rating

  • *****
  • Click to rate
  • 0 Rating(s)
  • 0
  • 0
  • 0
  • 0
  • 0
  • Home
  • /
  • Knowledge Base
  • /
  • WinHost
  • /
  • Programming, error messages and sample code
  • /
  • Sample code
  • /
  • How to insert data into an MS SQL database with .NET SQL Data Provider in ASP.NET
Actions
  • Print
  • Add Favorite
Share
  • Digg
  • Facebook
  • Twitter

How to insert data into an MS SQL database with .NET SQL Data Provider in ASP.NET

<%@ import namespace="system.data.sqlclient" %> 
<Script runat="server"> 
Sub page_load 
            Dim dbconn as sqlconnection 
            Dim dbCMD as sqlCommand 
            dbConn = New SQLConnection ("Data Source=DBSERVERNAME;Initial Catalog=YOURDBNAME;User ID=YOURUSERID;Password=YOURPASSWORD") 
            dbConn.open() 
            dbCMD = new sqlcommand ("insert into tblTest values ('test')",dbconn) 
            dbCMD.executenonquery() 
            dbConn.close() 
End Sub 
</Script> 
Record Inserted 

If you run in to problems using this code, please post in our community forum. Technical support cannot assist with specific coding related issues.

Article ID: 639, Created On: 8/14/2009, Modified: 4/21/2011

Comments (0)

  • Show More
  • Add Comment
Captcha
Submit
Management Interface
4 Active User(s)
  • © 2012 SmarterTools Inc.
  • |
  • Help Desk Software
  • |
  • SmarterTrack Enterprise 7.4
 
Cancel OK
Message