Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
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
Dalia
Posted 17-Dec-12 20:47pm
Comments
ACE_ at 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 at 19-Dec-12 18:45pm
   
try to write the complete name like databasename.schema.tablename, mostly schema would be dbo.
Member 8697827 at 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)
cn.Open()
Try
cn.ChangeDatabase("dd_db")
Catch ex As Exception
Try
Dim command As New SqlClient.SqlCommand("create database dd_db", cn)
command.ExecuteNonQuery()
command.Connection.ChangeDatabase("dd_db")
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),[blood.gp][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),[prior.bl][char](8),[type.blo][char](15),[number.o][char](15),[num.bl.t][int](2),[datel.bl][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)
command1.ExecuteNonQuery()
Catch ex1 As Exception
MsgBox(ex.Message)
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
Dalia
Member 8697827 at 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
good
Please Sign up or sign in to vote.

Solution 3

Take a look at Five different overloads of the DataAdapter.Fill() method[^] by http://www.codeproject.com/Members/Ravindra-T-C[^] and try da.Fill(ds) instead of da.Fill(ds, "dd_tb")
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 475
1 Maciej Los 339
2 Richard MacCutchan 225
3 BillWoodruff 219
4 Suraj Sahoo | Coding Passion 155
0 OriginalGriff 8,759
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,269
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web02 | 2.8.1411028.1 | Last Updated 22 Dec 2012
Copyright © CodeProject, 1999-2014
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