爱问知识人 爱问教育 医院库

VB与SQL Server2005数据库是怎样连接的、

首页

VB与SQL Server2005数据库是怎样连接的、

VB与SQL Server2005数据库是怎样连接的、更新、输出

提交回答
好评回答
  • 2008-11-26 12:17:00
      我自己写的代码,用ADO进行VB与SQL连接,用MSFlexGrid控件显示数据库中的数据~~首先要添加ADO引用和MSFlexGrid控件~~Private Sub Command1_Click() Dim con As New ADODB。
      Connection '定义ADO对象 Dim rs As New ADODB。Recordset Dim strsql As String Dim i As Integer con。ConnectionString = "provider=SQLOLEDB。
      1;data source=(local);initial Catalog=Student; integrated security=SSPI" '初始化对象,打开连接(Windows身份验证) con。Open strsql = "select * from Student" rs。
      Open strsql, con, 2, 2 '打开记录集 '使用rs填充控件 '初始化控件 With MSFlexGrid1 。Cols = rs。Fields。Count + 1 '设定表格列数,统计字段数量,列数要比字段数多一个(Fields。
      Count为字段数),第一列为空列,当记 录指示器用 。Rows = rs。RecordCount + 2 '使用 RecordCount 属性可确定Recordset对象中记录的数目。ADO 无法确定记录数时,或者如果提供 者或游标类型不支持 RecordCount,则该属性返回 1。
      即该初始化行数为1; 。ColWidth(2) = 1800 '第3列的宽度为1800 。TextMatrix(0, 0) = "序号" '设置第1行第1列的文本内容 。TextMatrix(0, 1) = rs(0)。Name '读出数据使用textmatrix属性,将第1个字段的名称赋值给 控件单元格 。
      TextMatrix(0, 2) = rs(1)。Name End With '填充控件 i = 1 While Not rs。EOF MSFlexGrid1。Rows = MSFlexGrid1。Rows + 1 '添加新行 MSFlexGrid1。
      TextMatrix(i, 0) = Str(i) MSFlexGrid1。TextMatrix(i, 1) = rs(0) '在当前记录中,将第1个字段的内容赋值给控件单元格 MSFlexGrid1。TextMatrix(i, 2) = rs(1) i = i + 1 rs。
      MoveNext '跳到下一条记录 Wend rs。Close con。Close End Sub。

    s***

    2008-11-26 12:17:00

其他答案

    2008-11-26 08:48:00
  • question:VB与SQL Server2005数据库是怎样连接的、更新、输出 5标签: sql,  vb,  数据库 VB与SQL Server2005数据库是怎样连接的,用什么语句进行数据库的更新以及输出数据库的内容的,高手帮帮忙,急用!!!!!!  ?HiS  回答:2  人气:1  提问时间:2008-11-25 12:50answer:c++  c#  vc  JAVA  DOT NET  数据库  程序开发语言 html 网站开发  软件工程  操作系统  网络安全  多媒体图像  IT认证考试  硬件综合  计算机学习  外语(以上有资料 有视频 更多学习交流和分享)   (  下资源需要要BFB 最好攒BFB 1小时有个50BFB 要学快去 晚了zc就关了wait are you waiting for?

    x***

    2008-11-26 08:48:00

  • 2008-11-26 08:04:00
  •   Public con As ADODB。Connection, Str As String, Adodc As ADODB。Recordset, sql As StringPublic Sub Ado_Open()con = New ADODB。
      ConnectionStr = "Driver={Microsoft Access Driver (*。mdb)};DBQ=" & System。IO。Directory。GetCurrentDirectory & "\ b;pwd=;ReadOnly=False"con。
      Open(Str)End SubPublic Sub NewAdo()Adodc = New ADODB。RecordsetAdodc。CursorLocation = UseClientAdodc。
      Open(sql, con, OpenDynamic, LockBatchOptimistic)End Subpublic sub commandbutton1()ado_open sql="select * from user"newadotextbox1= elds(0)end sub。

    风***

    2008-11-26 08:04:00

类似问题

换一换
  • 程序设计 相关知识

  • 电脑网络技术
  • 电脑网络

相关推荐

正在加载...
最新资料 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):