Asp. NET adding data instances to the database

Source: Internet
Author: User
Using SQL Server to establish a database Hovertree

Then use the following script to create the table Hovertree_usermessage

Use [hovertree]go/****** object:table [dbo]. [Hovertree_usermessage] ******/set ansi_nulls ongoset quoted_identifier ongocreate TABLE [dbo]. [Hovertree_usermessage] ([Hvtid] [int] IDENTITY (null,[hvttitle) [nvarchar] (+) null,[hvtcontent] [nvarchar] (max) Null,[hvtuser] [ NVARCHAR] [null,[hvttime] [datetime] null,[hvtreply] [nvarchar] (max) null,[hvtisshow] [bit] null,constraint [pk_ Hovertree_usermessage] PRIMARY KEY CLUSTERED ([Hvtid] ASC) with (Pad_index = off, Statistics_norecompute = off, ignore_dup_ KEY = OFF, allow_row_locks = on, allow_page_locks = on) on [PRIMARY]) on [Primary]goalter TABLE [dbo]. [Hovertree_usermessage] ADD CONSTRAINT [Df_hovertree_usermessage_hvttime] DEFAULT (GETDATE ()) for [Hvttime]go

Then C # uses the Keleyisqlhelper class to add data to the database code:

C # code

String m_sql= "INSERT into Hovertree_usermessage (Hvttitle,hvtcontent,hvtuser) VALUES ("  +sqltools.getquotes ( Txttitle.text) + ","   + sqltools.getquotes (txtcontent.text) + ","   +sqltools.getquotes (Txtuser.text) + ")";  Keleyisqlhelper.executesql (M_sql);

TextBox controls where Txttitle, Txtcontent, and Txtuser are ASP.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.