Click here to Skip to main content
13,147,044 members (63,448 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I made a form in visual basic and I want to connect with sql connection I write the code to create database and tables and there are no errors but I have a message that appear sqlException was unhandled invalid object name "unc_tb" at the line of program (da.Fill(ds,"unc_tb") and the form in run mode don't appear
How can I solve this problem
Thanks in advance
Posted 17-Dec-12 19:47pm
ACE_ 18-Dec-12 22:19pm
Can you write your code before error line?
that error "unc_tb" has doesn't exists, please make sure you had that table
Rohit Shrivastava 19-Dec-12 18:45pm
try to write the complete name like databasename.schema.tablename, mostly schema would be dbo.
Member 8697827 21-Dec-12 3:23am
Imports System.Data
Imports System.Data.SqlClient
Public Class Form1
Dim cn As SqlConnection
Dim ds As DataSet
Dim da As SqlDataAdapter
Dim r As DataRow
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strconnection As String = "data source=.\SqlExpress;initial catalog=master;integrated security=true"
cn = New SqlConnection(strconnection)
Catch ex As Exception
Dim command As New SqlClient.SqlCommand("create database dd_db", cn)
Dim command1 As New SqlClient.SqlCommand("create table dd_tb ([admi.num][int](10),[tran.num][int](4),[name][char](40),[age.reci][int](2),[sex.reci][char](8),[or.kid.d][char](22),[specify][char](50),[consang][char](20),[rec.b.g][char](8),[r_iggt][char](8),[r_iggr][char](12),[r_igmt][char](8),[r_igmr][char](12),[r_hcvt][char](8),[r_hcvr][char](12),[r_pcrt][char](8),[r_pcrr][char](12),[r_hbvt][char](8),[r_hbvr][char](12),[r_bpcrt][char](8),[r_bpcrr][char](12),[][char](10),[rhla_aa][int](8),[rhla_ab][int](8),[rhla_ba][int](8),[rhla_bb][int](8),[rdr_a][int](8),[rdr_b][int](8),[][char](8),[type.blo][char](15),[number.o][char](15),[][int](2),[][date](10),[erythrop][char](8),[hypr_pre][char](8),[rec_schi][char](8),dia_rec][char](22),[sit_urn][char](12),[dial_pre][char](8),[dia_typ][char](20))", cn)
Catch ex1 As Exception
End Try
End Try
da = New SqlDataAdapter("select * from dd_tb", cn)
Dim x As New SqlCommandBuilder(da)
ds = New DataSet()
da.Fill(ds, "dd_tb")
End Sub
End Class

This is the code at the line of da.Fill(ds, "dd_tb") after compile it brings this message sqlException was unhandled invalid object name "unc_dd" I tried unc_dd.dbo.unc_dd but it brings the same message
So can you help me to find the solution
Thanks in advance
Member 8697827 21-Dec-12 3:28am
I also tried da.Fill(da) but the same message appear
so I remove this line the form appear But at button new to add new to the database it brings this message nullReferenceException was unhandled object reference not set to an instance of an object

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Take a look at Five different overloads of the DataAdapter.Fill() method[^] by[^] and try da.Fill(ds) instead of da.Fill(ds, "dd_tb")

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170915.1 | Last Updated 22 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100