A technique used to write the asp.net Forum

Source: Internet
Author: User


I recently wrote an asp.net forum, and the vb.net forum is basically finished ..
I will share with you a method I used when writing code... although it is simple, it still has some reference value for beginners...
As you know, to write a dynamic web page, you must operate on the database and use the SQL language. Sometimes, if the SQL language is incorrectly written, the web page cannot run .. how can I check whether the SQL language is correctly written? In sqlserver, it is easy to use the query analyzer to try it, but it is not useful for access databases (considering the convenience of migration, I use access as a database). How can I check whether access is correct for an SQL language?
For example, I write this statement.
Select count (*) from articles where boardid = 1 or reply in (select id from articles where boardid = 1)
After writing it out, you cannot immediately determine whether it is correct. I use this method to handle it:
1. Write a simple page with three controls. You can see the figure.
The program of the onclick event triggered by button1 is as follows:
Private Sub button#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.exe cutescalar ()
End Sub
The specific implementation method is as follows:
[Color = # FF0000] obtain the SQL string from textbox1 and execute the SQL statement using button1. The execution result is displayed on label1. [/color]

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.