数据库连接问题?

changei123 2005-03-25 04:35:53
在VB.NET 中怎么连接数据库呀,我怎么连不对呀,请帮帮忙,谢谢各位大哥大姐们!1
...全文
74 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
hidejay 2005-03-27
  • 打赏
  • 举报
回复
oracle怎么连呢
水如烟 2005-03-25
  • 打赏
  • 举报
回复
不能类型的数据库其连接字串有所不同。
具体你可以参考这个:
http://www.connectionstring.com/
http://blog.joycode.com/ghj/articles/15312.aspx
点点星灯 2005-03-25
  • 打赏
  • 举报
回复
Const ConnStr As String = "packet size=4096;user id=xxx;data source=192.168.0.2;
persist security info=True;initial catalog=DC;password=xxx"


If SqlConn Is Nothing Then
SqlConn = New SqlClient.SqlConnection(ConnStr)
End If
SqlCom = New SqlClient.SqlCommand(SqlStr, SqlConn)
SqlConn.Close()
SqlConn.Open()



....
hamadou 2005-03-25
  • 打赏
  • 举报
回复
建议以后不要这样的问题也来问啊!看看帮助,msdn!
hamadou 2005-03-25
  • 打赏
  • 举报
回复
Public Sub InsertRow(myConnectionString As String)
' If the connection string is null, use a default.
If myConnectionString = "" Then
myConnectionString = "Initial Catalog=Northwind;Data Source=localhost;Integrated Security=SSPI;"
End If
Dim myConnection As New SqlConnection(myConnectionString)
Dim myInsertQuery As String = "INSERT INTO Customers (CustomerID, CompanyName) Values('NWIND', 'Northwind Traders')"
Dim myCommand As New SqlCommand(myInsertQuery)
myCommand.Connection = myConnection
myConnection.Open()
myCommand.ExecuteNonQuery()
myCommand.Connection.Close()
End Sub 'SelectSqlClientSrvRows

16,721

社区成员

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

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