| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 771 人关注过本帖
标题:关于vb.net的数据连接,急
取消只看楼主 加入收藏
sugala
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2010-6-24
结帖率:0
收藏
已结贴  问题点数:20 回复次数:0 
关于vb.net的数据连接,急
我是初学者,最近要交一份期末作业,做了个小系统,用到了数据库,我是用ACCESS建的。。
做好了 ,系统没提示错误,但每当运行到 有关连接到数据库的 时候  就会跳出个提示“在建立与服务器的连接时出错。在连接到 SQL Server 2005 时,在默认的设置下 SQL Server 不允许进行远程连接可能会导致此失败。 (provider: SQL 网络接口, error: 26 - 定位指定的服务器/实例时出错)”

这是什么原因呢。是不是 代码用的 是SQL建的数据库?还是有什么其他的问题。

忘能者帮忙,万分感谢,明天就要交作业了。。有好心人,可以加下我Q,帮我改下。。。太感谢了。。我的qq:1511272703


一下是一个界面的代码:
Imports System.Data
Imports System.Data.SqlClient
Public Class 员工档案查询
    Inherits System.Windows.Forms.Form
    Dim strconn As String = "Data Source=F:\10学校\vb\期末\人事管理系统\人事管理系统\员工基本信息管理系统.mdb;initial catalog=员工基本信息管理系统;"

    Dim objds As New Data.DataSet
    Dim objda As SqlClient.SqlDataAdapter
    Dim bingpage As BindingManagerBase
    Dim strsql As String
    Dim cmd As SqlCommandBuilder
    Dim dt As New DataTable
    Private Sub 员工档案查询_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: 这行代码将数据加载到表“员工基本信息管理系统DataSet.员工档案表”中。您可以根据需要移动或移除它。
        Me.员工档案表TableAdapter.Fill(Me.员工基本信息管理系统DataSet.员工档案表)

        strsql = "select * from 员工档案表"
        objda = New SqlClient.SqlDataAdapter(strsql, strconn)
        objda.Fill(objds, "员工档案表")   \\  运行该界面的时候,缓冲了一会儿 就会跳到编码界面,这句话变黄色,并提示上面的错误。
        DataGridView1.DataSource = objds.Tables("员工档案表")
        bingpage = Me.BindingContext(objds, "员工档案表")
        TextBox1.DataBindings.Add(New Binding("text", objds, "员工档案表.员工号"))
        TextBox2.DataBindings.Add(New Binding("text", objds, "员工档案表.姓名"))
        TextBox3.DataBindings.Add(New Binding("text", objds, "员工档案表.性别"))
        TextBox4.DataBindings.Add(New Binding("text", objds, "员工档案表.民族"))
        TextBox5.DataBindings.Add(New Binding("text", objds, "员工档案表.出生日期"))
        TextBox5.Text = CDate(TextBox5.Text)
        TextBox6.DataBindings.Add(New Binding("text", objds, "员工档案表.政治面貌"))
        TextBox7.DataBindings.Add(New Binding("text", objds, "员工档案表.身份证号"))
        TextBox8.DataBindings.Add(New Binding("text", objds, "员工档案表.学历"))
        TextBox9.DataBindings.Add(New Binding("text", objds, "员工档案表.毕业院校"))
        TextBox10.DataBindings.Add(New Binding("text", objds, "员工档案表.部门"))
        TextBox11.DataBindings.Add(New Binding("text", objds, "员工档案表.职称"))
        TextBox12.DataBindings.Add(New Binding("text", objds, "员工档案表.工资"))
        TextBox13.DataBindings.Add(New Binding("text", objds, "员工档案表.录取时间"))
        TextBox13.Text = CDate(TextBox13.Text)
        TextBox14.DataBindings.Add(New Binding("text", objds, "员工档案表.合同有效期"))
        TextBox14.Text = CDate(TextBox14.Text)
        TextBox15.DataBindings.Add(New Binding("text", objds, "员工档案表.电话号码"))
        TextBox16.DataBindings.Add(New Binding("text", objds, "员工档案表.备注"))
        ComboBox1.Items.Add("员工号")
        ComboBox1.Items.Add("姓名")
        ComboBox1.Items.Add("部门")
        ComboBox1.Items.Add("出生日期")
        TextBox1.ReadOnly = True
        TextBox2.ReadOnly = True
        TextBox3.ReadOnly = True
        TextBox4.ReadOnly = True
        TextBox5.ReadOnly = True
        TextBox6.ReadOnly = True
        TextBox7.ReadOnly = True
        TextBox8.ReadOnly = True
        TextBox9.ReadOnly = True
        TextBox10.ReadOnly = True
        TextBox11.ReadOnly = True
        TextBox12.ReadOnly = True
        TextBox13.ReadOnly = True
        TextBox14.ReadOnly = True
        TextBox15.ReadOnly = True
        TextBox16.ReadOnly = True

    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        bingpage.Position = 0
        Button1.Enabled = False
        Button2.Enabled = False
        Button3.Enabled = True
        Button4.Enabled = True
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        bingpage.Position = bingpage.Position - 1
        If bingpage.Position <> 1 Then
            Button1.Enabled = True
            Button2.Enabled = True
            Button2.Enabled = True
            Button3.Enabled = True
        Else
            Button1.Enabled = False
            Button2.Enabled = False
            Button3.Enabled = True
            Button4.Enabled = True
        End If
    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        bingpage.Position = bingpage.Position + 1
        If bingpage.Position <> bingpage.Count - 1 Then
            Button1.Enabled = True
            Button2.Enabled = True
            Button3.Enabled = True
            Button4.Enabled = True
        Else
            Button1.Enabled = True
            Button2.Enabled = True
            Button3.Enabled = False
            Button4.Enabled = False
        End If
    End Sub
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        bingpage.Position = bingpage.Count - 1
        Button1.Enabled = True
        Button2.Enabled = True
        Button3.Enabled = False
        Button4.Enabled = False
    End Sub
    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        objds.Clear()
        If ComboBox1.Text = "" Or TextBox17.Text = "" Then
            MessageBox.Show("请输入查询条件!")
            Exit Sub
        Else
            strsql = "select * from 员工档案表 where " & Trim(ComboBox1.Text) & "=" & "'" & Trim(TextBox17.Text) & "'"
            objda = New SqlClient.SqlDataAdapter(strsql, strconn)
            objda.Fill(dt)
            cmd = New SqlCommandBuilder(objda)
            DataGridView1.DataSource = dt
            If dt.Rows.Count = 0 Then
                MessageBox.Show(" 不存在该员工的信息!")
                Exit Sub
            End If
        End If
    End Sub
    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        objds.Clear()
        strsql = "select * from 员工档案表"
        objda = New SqlClient.SqlDataAdapter(strsql, strconn)
        objda.Fill(objds, "员工档案表")
        DataGridView1.DataSource = objds.Tables("员工档案表")
    End Sub

  

End Class


[ 本帖最后由 sugala 于 2010-6-24 15:57 编辑 ]
搜索更多相关主题的帖子: 数据 
2010-06-24 15:16
快速回复:关于vb.net的数据连接,急
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.036544 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved