新人先报到 以后再问..
vb.net吧
全部回复
仅看楼主
level 3
[狂汗]我竟然是第5800多个关注的 竟然能是四位数 隔壁的 准备转.net学习学习 以后有不会的 还请各位大大多帮忙
2018年01月23日 06点01分 1
level 11
那你要加油哟~
2018年01月23日 07点01分 2
11级大大给暖楼[太开心]
2018年01月23日 07点01分
2018年01月23日 07点01分
level 3
[不高兴]刚开始写程序发现语法变得好多啊 边研究边试...可算是把登陆写好了...分享下吧.
总体来说写着有点懵圈。。
Module Module2
Public conn As ADODB.Connection '声明记录集
Public rs As ADODB.Recordset '声明结果集
Public Link As String '定义link数据库字符串
Public Loginname As String '定义登陆窗口名字返回值
Public loginpass As String '定义登陆窗口密码返回值
Public loginid As String '定义登陆窗口编号返回值
Public jg As String '定义注册成功后返回的结果
Public Sub Lj()
Dim DbUser As String, DbPw As String
Dim DbName As String, DbIP As String
DbUser = "sa" '用户名
DbPw = "1" '密码
DbName = "demon" '数据库名
DbIP = "127.0.0.1" '服务器地址
Link = "driver={sql server}"
Link = Link & ";server=" & DbIP
Link = Link & ";uid=" & DbUser
Link = Link & ";pwd=" & DbPw
Link = Link & ";Database=" & DbName
conn = New ADODB.Connection
rs = New ADODB.Recordset '建立无源数据库连接
conn.ConnectionString = Link '字符串赋值
conn.ConnectionTimeout = 50 '反应时间
conn.Open '打开记录源
rs.ActiveConnection = conn '设置游标类型
rs.CursorType = ADODB.CursorTypeEnum.adOpenDynamic '游标类型
End Sub
Public Function SelLogin(sjk As String, id As String, password As String, name As String) '登陆界面添加
Dim sql As String
sql = "select * from " & sjk & " where id='" & id & "'" '查询ID
rs.Open(sql, conn)
If rs.EOF = True Then '如果这个末尾是空
Loginname = "" '返回值赋空
Else
Loginname = Trim(rs.Fields("name").Value) '如果有记录 返回值赋值回去
loginid = Trim(rs.Fields("id").Value)
loginpass = Trim(rs.Fields("password").Value)
End If
End Function
End Module
Public Class Form1
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Then
MsgBox("用户名编号或密码没有填写!", vbOKOnly + vbExclamation, "警告")
Else
Call Lj()
Call SelLogin("login_user", TextBox1.Text, TextBox2.Text, Label1.Text)
If rs.EOF = True Then
MsgBox("没有这个用户ID,请重新输入用户名!", vbOKOnly + vbExclamation, "警告")
TextBox1.Focus()
Else
If (Trim(TextBox2.Text)) = loginpass Then
Form2.Show()
Else
MsgBox("输入的密码不正确!", vbOKOnly + vbExclamation, "警告")
TextBox2.Focus()
TextBox2.SelectAll()
End If
End If
End If
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
If TextBox1.Text = "" Then
Exit Sub
Else
Call Lj() '链接数据库
Call SelLogin("login_user", TextBox1.Text, TextBox2.Text, Label4.Text)
Label4.Text = Loginname '读取操作员名称
End If
End Sub
End Class
2018年01月24日 01点01分 3
level 3
Function GetFromIni(strSectionHeader As String, strVariableName As String, strFileName As String) As String '读取配置文件的API函数
Dim strReturn As String
strReturn = String(255, Chr(0))
GetFromIni = Left(strReturn, GetPrivateProfileString(strSectionHeader, ByVal strVariableName, "", strReturn, Len(strReturn), strFileName))
End Function
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
On Error GoTo 123
Dim fwq As String
'192.168.11.202 2L02
fwq = "\\2l02\UPDemon\updata.ini" '这里填写2L02 二楼更新服务器
If Dir(fwq) = "" Then '目录
GoTo 123
Exit Sub
Else
cfg = fwq '目录
up$ = "Demon" '配置头
strtempht1 = GetFromIni(up$, "版本号", cfg)
strtempht2 = GetFromIni(up$, "更新1", cfg)
strtempht3 = GetFromIni(up$, "更新2", cfg)
strtempht4 = GetFromIni(up$, "更新3", cfg)
strtempht5 = GetFromIni(up$, "更新4", cfg)
strtempht6 = GetFromIni(up$, "更新5", cfg)
strtempht7 = GetFromIni(up$, "更新6", cfg)
Label11.Text = "最新版本号:" & strtempht1
Label5.Text = strtempht2
Label6.Text = strtempht3
Label7.Text = strtempht4
Label8.Text = strtempht5
Label9.Text = strtempht6
'Label12.Caption = strtempht7
If strtempht1 <> Mid(Me.GroupBox1.Text, 5) Then '版本号标签
Button2.Enabled = True
If strtempht7 = "" Then
Exit Sub
Else
MsgBox(strtempht7, vbOKOnly + vbExclamation, "警告")
'Image1.Enabled = False
'Image1.Picture = LoadPicture(App.Path & "\IMG\gx.jpg")
End If
Exit Sub
End If
End If
Exit Sub
123:
Label4.Text = "更新系统发生错误,暂时无法检查更新"
Exit Sub
End Sub
End Class
这段读取INI 应该怎么修改呢?
提示“String”是一个类类型,不能用作表达式。
“Public Overloads Property Left As Integer”没有任何参数,并且无法对它的返回类型进行索引。
2018年01月24日 02点01分 4
level 11
建议你先看编码规范再继续玩下搞,msdn有
2018年01月24日 04点01分 5
level 10
建议你数据库还是用.net的吧....
SqlServer用SqlConnection
其他的用OleConnection
当然MySql自己提供了库....
2018年01月24日 06点01分 6
level 3
慢慢研究[汗]
2018年01月24日 06点01分 7
1