A technique for writing a asp.net forum

Source: Internet
Author: User
Asp.net| Tips

Recently in writing a asp.net forum, vb.net's forum was basically finished.
When I write code, I use a method to share with you ... Although simple, but for beginners I think there is a certain reference value ...

You know, write a Dynamic Web page is sure to operate on the database, use the SQL language, sometimes, if the SQL language is not written correctly, the Web page can not run. How to detect whether the SQL language is written correctly, it is easy to use Query Analyzer in SQL Server to try on the OK, but for Access database is not useful (due to the portability of the problem, I use Access to do the database), So how do you detect whether an SQL language is correct for access?
For example, I write this statement
Select COUNT (*) from articles where boardid=1 or reply in (select ID from articles where boardid=1)

When it is written, it cannot be judged right at once, and I am dealing with it in this way:
1 Write a simple page that includes three controls everybody look at the picture, see?

Where Button1 's onclick triggers the event's program as follows:

Private Sub button1_click (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles Button1.Click
Dim str as String = Trim (TextBox1.Text)
Dim mycommand = New OleDbCommand (STR, conn)
Conn. Open ()
Label1.Text = Mycommand.executescalar ()
End Sub

The specific implementation methods are:
Gets the SQL string from the textbox1 and executes the SQL statement through Button1, and the execution results are displayed on the Label1 above



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.