标题:请大神帮我看一下这个代码那里有错
取消只看楼主
zhongsw520
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2018-2-21
结帖率:0
已结贴  问题点数:20 回复次数:0 
请大神帮我看一下这个代码那里有错
Imports System.Data.SqlClient

Public Class Form1
    Dim conn As New SqlConnection()
    Dim cmd As New SqlCommand
    Dim datard As SqlDataReader

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim constr As String '连接数据源
        constr = "user id=sa;password=123456;initial catalog=rsgl;data source=(local)"
        conn.ConnectionString = constr
        conn.Open()
        cmd.Connection = conn  '命令对像连接
         = CommandType.Text
        Dim cmdstr As String  '定义连接查询语句
        cmdstr = "select * from 用户表 "
         = cmdstr
        Dim datard As SqlDataReader  '定义读取方式
        datard = cmd.ExecuteReader
        Dim AA As String
        AA = datard.Read
        If datard.Item(CInt("psw")) = TextBox1.Text Then
            'TextBox1.Text = datard.GetString(1)
            TextBox2.Text = datard.GetString(2)
            datard.Close()
            conn.Close()
        Else
            MsgBox("输入不正确")

        End If
搜索更多相关主题的帖子: Dim conn cmd String Text 
2018-02-22 14:46



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-484819-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.134500 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved