| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1644 人关注过本帖
标题:请教各位大佬看看有无错误,SQL运行结果:rs.Open(sql, conn)参数类型不正确 ...
只看楼主 加入收藏
leokk
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2019-6-23
结帖率:0
收藏
 问题点数:0 回复次数:1 
请教各位大佬看看有无错误,SQL运行结果:rs.Open(sql, conn)参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突
Public Class Form9
    Dim conn As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim rss As New ADODB.Recordset
    Dim str As String
    Dim sql As String
    Private Sub Form9_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        conn = OpenConn()

        sql = "select 药品编号 from 药品信息"
        ComboBox2.Items.Clear()
        rs.Open(sql, conn)
        Do While Not rs.EOF
            str = Trim(rs(0).Value)
            ComboBox2.Items.Add(str)
            rs.MoveNext()
        Loop
        rs.Close()
        sql = "select 病人编号 from 病人信息 "
        ComboBox1.Items.Clear()
        rs.Open(sql, conn)
        Do While Not rs.EOF
            str = Trim(rs(0).Value)
            ComboBox1.Items.Add(str)
            rs.MoveNext()
        Loop
        rs.Close()
    End Sub


    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        If Trim(ComboBox1.SelectedItem) = "" Then
            MsgBox("请选择病人!")
            Exit Sub
        End If
        If Trim(ComboBox2.SelectedItem) = "" Then
            MsgBox("请选择药品!")
            Exit Sub
        End If
        sql = "insert into 配药单 values('" & Trim(ComboBox1.SelectedItem) & "','" & Trim(ComboBox2.SelectedItem) & "',GETDATE(),'" & Trim(TextBox2.Text) & "')"
        rs.Open(sql, conn)

        sql = "update 病人信息 set 总费用 = 总费用 + " & Int(Trim(TextBox2.Text)) * Int(Trim(TextBox1.Text)) & " where 病人编号 = '" & Trim(ComboBox1.SelectedItem) & "'"
        rs.Open(sql, conn)

        MsgBox("添加成功")


        Me.Close()
        CloseConn(conn)

    End Sub

    Private Sub TextBox1_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox1.TextChanged
    End Sub

    Private Sub TextBox2_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox2.TextChanged
        If (TextBox2.Text <> "") Then
            Label5.Text = "总价格为" & Int(Trim(TextBox2.Text)) * Int(Trim(TextBox1.Text)) & "元"
        End If

    End Sub

    Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click
        Me.Close()
    End Sub

    Private Sub ComboBox2_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
        sql = "select 价格 from 药品信息 where 药品编号 = '" & Trim(ComboBox2.SelectedItem) & "'"
        rs.Open(sql, conn)
        TextBox1.Text = Trim(rs(0).Value)
        rs.Close()
    End Sub

    Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub
End Class
     
搜索更多相关主题的帖子: sql conn Sub System Trim 
2019-06-23 19:48
leokk
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2019-6-23
收藏
得分:0 
打错了,
是vs运行结果
2019-06-23 19:49
快速回复:请教各位大佬看看有无错误,SQL运行结果:rs.Open(sql, conn)参数类型 ...
数据加载中...
 
   



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

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