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