
------解决方案--------------------
http://blog.csdn.net/lidatgb/article/details/7196879
------解决方案--------------------
这只是一个窗体,你要通过窗体输入,再连接数据库?
------解决方案--------------------
我想你这个是通过窗体输入数据库相关信息并写入到 app.config配置文件里,
------解决方案--------------------
那你的数据连接串
Dim ConnString As String = _
"Data Source="& textbox1.text & "," & textbox2.text & ";Initial Catalog=data;Persist Security Info=True;User ID=" & textbox3.text & ";Password=" & textbox4.text
------解决方案--------------------
接下来是连接数据库,通过查询,返回记录
Dim sqltxt As String = "select * from table" '定义sql语句
Dim sqlconn As New SqlConnection(ConnString) '定义连接
Dim sqlcmd As New SqlCommand(sqltxt, sqlconn) '定义sqlCommand
Dim userReader As SqlDataReader '定义sqldatareader
Try
sqlconn.Open() '打开连接
userReader = sqlcmd.ExecuteReader '生成sqldatareader
userReader.Read() '读取数据
MsgBox(userReader.Item(3)) '显示读取的第四个数据
userReader.Close() '关闭阅读
Catch ex As Exception
MsgBox(ex.Message)
Finally
sqlcmd.Dispose() ' 释放sqlCommand
End Try
------解决方案--------------------
读取一条记录中的第4个数据
在确定按钮中放这个代码
------解决方案--------------------
你要对数据库的读取要了解,不然你很难解决问题的
------解决方案--------------------
好的,仔细看一下我给的这个网址,
------解决方案--------------------
应该与你的数据库连接不上,你要确定通过数据库的IP或计算机名,你能连接上数据库