十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
重要的是区别两个方法:DbAdapter.Fill是读,DbCommand.ExecuteNonquery是执行修改。删除按钮下理论上应先调用修改,确认成功后,再调用读取。
成都创新互联公司 - 四川乐山服务器托管,四川服务器租用,成都服务器租用,四川网通托管,绵阳服务器托管,德阳服务器托管,遂宁服务器托管,绵阳服务器托管,四川云主机,成都云主机,西南云主机,四川乐山服务器托管,西南服务器托管,四川/成都大带宽,成都机柜租用,四川老牌IDC服务商
下面这段代码,是我用来计算每个月存500元进银行,连续30年,最后连本带利能有多少钱。这里面涉及复利计算。界面中右边的文本框用来输出每一次计算的结果。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim nianxian As Integer '年限变量
Dim dingcun As Integer '定存变量
Dim fuli_big As Long '大复利
Dim fuli_small As Long '小复利
Dim i As Integer '循环变量
Dim DATAstring As String '数据字符串
nianxian = Val(年限_TextBox.Text)
dingcun = Val(定存_TextBox.Text)
DATAstring = ""
For i = 1 To nianxian
fuli_small = dingcun * (1 + 0.1875)
dingcun = fuli_small
fuli_big = fuli_big + fuli_small
DATAstring = DATAstring + "[" + Trim(Str(i)) + "]" + Str(fuli_big) + Chr(13) + Chr(10)
'DATAstring = DATAstring + "[" + Trim(Str(i)) + "]" + Str(fuli_small) + Chr(13) + Chr(10)
Next
'fuli_big = fuli_small
TextBox1.Text = DATAstring
结果_TextBox.Text = Str(fuli_big) + "元"
End Sub
很简单的。这个最基本的了。
就是从数据库表中 找出一个记录,名称和密码都和你输入的一样的记录,就表示登陆成功。
简单的思路:(密码也没有加密等)
dim dt As New DataTable
dim cmd As New SqlCommand
With cmd
.CommandText = "Select * From Users Where UserName=@UserName and UserPwd=@UserPwd"
.Parameters.Add(New SqlClient.SqlParameter("@UserName", "=你输入的用户名TextBox1.Text"))
.Parameters.Add(New SqlClient.SqlParameter("@strColorNo", "=你输入的密码TextBox2.Text"))
End With
dt =SqlHelper.GetDatatable(cmd)
if dt.rows.count0 then
msgbox "ok"
else
msgbox "error"
end if
引用Microsoft SQLDMO Object Library
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim SQLSER As New SQLDMO.SQLServer
SQLSER.Connect(ServerName, UserName, PassWord) '这三项换为你自己的
PBackup.Database = DatabaseName '数据库名
Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
Dim PathName As String
PathName = "D:\BackUp"
PBackup.Files = PathName
PBackup.SQLBackup(SQLSER)
SQLSER.DisConnect()
SQLSER = Nothing
Me.Cursor = System.Windows.Forms.Cursors.Default
MsgBox("成功备份了数据")
End Sub