ASP.NET adds data instance to database

巴扎黑
Release: 2016-12-19 16:00:47
Original
2295 people have browsed it

Use Sql Server to create 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 ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[hovertree_usermessage](
[hvtId] [int] IDENTITY(1,1) NOT NULL,
[hvtTitle] [nvarchar](500) NULL,
[hvtContent] [nvarchar](max) NULL,
[hvtUser] [nvarchar](50) 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]
GO
ALTER TABLE [dbo].[hovertree_usermessage] ADD CONSTRAINT [DF_hovertree_usermessage_hvtTime] DEFAULT (getdate()) FOR [hvtTime]
GO
Copy after login

Then the C# code for using the KeleyiSQLHelper class to add data to the database is:

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);
Copy after login

where txtTitle, txtContent, and txtUser are ASP.NET TextBox control

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!