| |

VerySource

 Forgot password?
 Register
Search
View: 594|Reply: 1

Seeking to use the simplest VB.NET language to connect SQL in ASP.NET

[Copy link]

4

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-25 12:40:01
| Show all posts |Read mode
I don't want to use in Default.aspx
   
<% @ Import Namespace = "System.Data"%>
<% @ Import Namespace = "System.Data.Sqlclient"%>
   
This method is connected to SQL. I want to write in VB.NET language in Default.aspx.vb. Please give me the simplest connection method, because I am a novice, I am afraid that it is too deep
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-13 21:45:01
| Show all posts
At the top of the Default.aspx.vb page, you also have to quote this code Imports System.Data.SqlClient
Then code in the database to give a simple example.
Dim con As New SqlConnection ("server = .; database = jie; uid = sa; pwd =;")
// server =. represents the local database connected, database writes the database name you want to connect, user name and password to write your own.
        Dim cmd As New SqlCommand ("select Uid from user table where user name = '"&TextBox1.Text&"' and user password = '"&TextBox2.Text&"'", con)
        Dim dr As SqlDataReader
        con.Open ()
        dr = cmd.ExecuteReader
        If dr.Read Then
            Response.Redirect ("WebForm1.aspx")
        Else
            Response.Write ("<script> alert ('The username or password is wrong') </ script>")

        End If
        dr.Close ()
        con.Close ()
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list