页面之间传递数据方法之一(查询字符串)

1、使用传递字符串:
Dim sql As String
        sql = "select xingming=count(*) from login where gys_name='" & tb_kehu.Text & "'and gys_password='" & tb_mima.Text & "'"
        SqlConnection1.Open()
        SqlCommand1.CommandText = sql
        Dim reader As SqlClient.SqlDataReader
        reader = SqlCommand1.ExecuteReader
        If reader.Read Then
            If reader("xingming") > 0 Then
                Me.Response.Redirect("result.aspx?name=" & System.Web.HttpUtility.HtmlEncode(tb_kehu.Text) & " & password=" & System.Web.HttpUtility.HtmlEncode(tb_mima.Text))
            Else
                Label4.Text = "你输入的用户名或密码错误,请核实后输入!"
            End If
        End If
        reader.Close()
        SqlConnection1.Close()

2、接受查询字符串变量
Sub datagrid()
        Dim MyCommand As SqlDataAdapter
        Dim MyConnection As SqlConnection
        Dim SelectCommand As String = "select * from user_login where gys_id = @gys_id order by id "
        MyConnection = New SqlConnection("workstation id=WEIZHI;packet size=4096;integrated security=SSPI;initial catalog=p" & _
        "rovide;persist security info=False")
        MyCommand = New SqlDataAdapter(SelectCommand, MyConnection)
        MyCommand.SelectCommand.Parameters.Add(New SqlParameter("@gys_id", SqlDbType.NVarChar, 50))
        MyCommand.SelectCommand.Parameters("@gys_id").Value = Request.Params("name")
        Dim DS As New DataSet
        MyCommand.Fill(DS, "user_login")
        myDataGrid.DataSource = DS.Tables("user_login").DefaultView
        myDataGrid.DataBind()
        With ddl
            .DataSource = DS.Tables("user_login").DefaultView
            .DataSource = DS
            .DataTextField = "spbh"
            .DataBind()
        End With

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

老卫-web全栈开发

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值