vb.net里这样连接数据库

opet_zhu 2003-07-31 06:26:10
那位兄弟姐妹有vb.net连接数据库的实例,请给我寄一个
谢谢!!
opet@sina.com
或那位可以教小弟一下,这么连接。简单一些就可以
我用服务器资源管理
小弟在线等待谢谢!
...全文
24 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
michael3769 2003-07-31
  • 打赏
  • 举报
回复
Dim connstr As String = "server=localhost;uid=sa;pwd=aa;database=aaaa"
Dim conn As SqlConnection = New SqlConnection(connstr)
Dim Cmd, cmd1 As SqlCommand
Dim reader As SqlDataReader
Dim sSQL As String
Dim server_pass As String

server_pass = Application("server_pass")

sSQL = "Select gcbm ,gclb ,tzze From datatablename)"
' 建立数据库链接
conn = New SqlConnection("data source=localhost;initial catalog=jianguan;persist security info=True;user id=sa;password=" + server_pass + ";workstation id=win2000;packet size=4096")
conn.Open()
'用SQL语句建立一个Command对象

Cmd = New SqlCommand(sSQL, conn)
reader = Cmd.ExecuteReader()

opet_zhu 2003-07-31
  • 打赏
  • 举报
回复
打开数据库后这么连??
sunbob 2003-07-31
  • 打赏
  • 举报
回复
Private strConnection As String
Dim cn As SqlClient.SqlConnection

strConnection = "Persist Security Info=False;User ID=sa;password=123;database=workdatabase;server=server2000;Connect Timeout=30" '"Server=founder;Database=base;User Id=sa;Password=123;"


'first,establish the connection
cn = New SqlClient.SqlConnection()
'获得连接字符
cn.ConnectionString = strConnection
cn.Open()
opet_zhu 2003-07-31
  • 打赏
  • 举报
回复
老兄有没有具体的例子
孟子E章 2003-07-31
  • 打赏
  • 举报
回复
http://www.csdn.net/Develop/read_article.asp?id=16437

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧