473,818 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Please help, about primary key and dataset

I am using the example from the microscuzz site on making a key but It keeps
giving me an error:

With DataSets.Tables ("Numbers")
.PrimaryKey = New DataColumn() {.Columns("Numb er")}
End With

Error:
Object reference not set to an instance of an object.

New is there, what is it talking about? Below is my code.

My wall has a hole now........

Thanks
Public Function GetAdapterandDa taset(ByRef con As OleDb.OleDbConn ection,
ByRef Msql As String, ByRef InsertDeleteUpd ate As String)

Dim DAdapter As OleDb.OleDbData Adapter = New OleDb.OleDbData Adapter(Msql,
con)

Dim CBuild As New OleDb.OleDbComm andBuilder

Dim DataSets As New DataSet

DAdapter.Fill(D ataSets, "Tables")

'create pkey

With DataSets.Tables ("Numbers")

..PrimaryKey = New DataColumn() {.Columns("Numb er")}

End With

'set command

Select Case InsertDeleteUpd ate

Case "Insert"

DAdapter.Insert Command = CBuild.GetInser tCommand()

Case "Update"

DAdapter.Insert Command = CBuild.GetUpdat eCommand()

Case "Delete"

DAdapter.Insert Command = CBuild.GetDelet eCommand()

End Select

'use the Dataadapter.upd ate (Dataset,"Table ")

'use the ds.acceptchange s to

Dim returnit As New Returnit

returnit.DA = DAdapter

returnit.DS = DataSets

Return returnit

End Function
Nov 17 '06 #1
5 1369
Hi,

Are you sure there is a column named Number?

Ken
------------------------
"Warex" <Ig************ @juno.comwrote in message
news:u7******** ******@TK2MSFTN GP03.phx.gbl...
>I am using the example from the microscuzz site on making a key but It
keeps giving me an error:

With DataSets.Tables ("Numbers")
.PrimaryKey = New DataColumn() {.Columns("Numb er")}
End With

Error:
Object reference not set to an instance of an object.

New is there, what is it talking about? Below is my code.

My wall has a hole now........

Thanks
Public Function GetAdapterandDa taset(ByRef con As OleDb.OleDbConn ection,
ByRef Msql As String, ByRef InsertDeleteUpd ate As String)

Dim DAdapter As OleDb.OleDbData Adapter = New OleDb.OleDbData Adapter(Msql,
con)

Dim CBuild As New OleDb.OleDbComm andBuilder

Dim DataSets As New DataSet

DAdapter.Fill(D ataSets, "Tables")

'create pkey

With DataSets.Tables ("Numbers")

.PrimaryKey = New DataColumn() {.Columns("Numb er")}

End With

'set command

Select Case InsertDeleteUpd ate

Case "Insert"

DAdapter.Insert Command = CBuild.GetInser tCommand()

Case "Update"

DAdapter.Insert Command = CBuild.GetUpdat eCommand()

Case "Delete"

DAdapter.Insert Command = CBuild.GetDelet eCommand()

End Select

'use the Dataadapter.upd ate (Dataset,"Table ")

'use the ds.acceptchange s to

Dim returnit As New Returnit

returnit.DA = DAdapter

returnit.DS = DataSets

Return returnit

End Function


Nov 17 '06 #2
Yes, my table name is "Numbers" and the field name of the first column is
"Number"

but I will look at it again......

out of curiosity why did microscam change data? recordsets worked fine for
me.....
"Ken Tucker [MVP]" <vb***@bellsout h.netwrote in message
news:uI******** *******@TK2MSFT NGP04.phx.gbl.. .
Hi,

Are you sure there is a column named Number?

Ken
------------------------
"Warex" <Ig************ @juno.comwrote in message
news:u7******** ******@TK2MSFTN GP03.phx.gbl...
>>I am using the example from the microscuzz site on making a key but It
keeps giving me an error:

With DataSets.Tables ("Numbers")
.PrimaryKey = New DataColumn() {.Columns("Numb er")}
End With

Error:
Object reference not set to an instance of an object.

New is there, what is it talking about? Below is my code.

My wall has a hole now........

Thanks
Public Function GetAdapterandDa taset(ByRef con As OleDb.OleDbConn ection,
ByRef Msql As String, ByRef InsertDeleteUpd ate As String)

Dim DAdapter As OleDb.OleDbData Adapter = New OleDb.OleDbData Adapter(Msql,
con)

Dim CBuild As New OleDb.OleDbComm andBuilder

Dim DataSets As New DataSet

DAdapter.Fill( DataSets, "Tables")

'create pkey

With DataSets.Tables ("Numbers")

.PrimaryKey = New DataColumn() {.Columns("Numb er")}

End With

'set command

Select Case InsertDeleteUpd ate

Case "Insert"

DAdapter.Inser tCommand = CBuild.GetInser tCommand()

Case "Update"

DAdapter.Inser tCommand = CBuild.GetUpdat eCommand()

Case "Delete"

DAdapter.Inser tCommand = CBuild.GetDelet eCommand()

End Select

'use the Dataadapter.upd ate (Dataset,"Table ")

'use the ds.acceptchange s to

Dim returnit As New Returnit

returnit.DA = DAdapter

returnit.DS = DataSets

Return returnit

End Function



Nov 17 '06 #3
Warex,

Are you using your recordset as well on a mobile device or as a disconnected
set on the Network.

However, you can still use your recordset, with all problems that are with
it.
If you did not have those, nobody is telling you that you may not use
recordset the pain now or in future is still for you.

Cor

"Warex" <Ig************ @juno.comschree f in bericht
news:Ow******** ******@TK2MSFTN GP04.phx.gbl...
Yes, my table name is "Numbers" and the field name of the first column is
"Number"

but I will look at it again......

out of curiosity why did microscam change data? recordsets worked fine for
me.....
"Ken Tucker [MVP]" <vb***@bellsout h.netwrote in message
news:uI******** *******@TK2MSFT NGP04.phx.gbl.. .
>Hi,

Are you sure there is a column named Number?

Ken
------------------------
"Warex" <Ig************ @juno.comwrote in message
news:u7******* *******@TK2MSFT NGP03.phx.gbl.. .
>>>I am using the example from the microscuzz site on making a key but It
keeps giving me an error:

With DataSets.Tables ("Numbers")
.PrimaryKey = New DataColumn() {.Columns("Numb er")}
End With

Error:
Object reference not set to an instance of an object.

New is there, what is it talking about? Below is my code.

My wall has a hole now........

Thanks
Public Function GetAdapterandDa taset(ByRef con As OleDb.OleDbConn ection,
ByRef Msql As String, ByRef InsertDeleteUpd ate As String)

Dim DAdapter As OleDb.OleDbData Adapter = New
OleDb.OleDbDa taAdapter(Msql, con)

Dim CBuild As New OleDb.OleDbComm andBuilder

Dim DataSets As New DataSet

DAdapter.Fill (DataSets, "Tables")

'create pkey

With DataSets.Tables ("Numbers")

.PrimaryKey = New DataColumn() {.Columns("Numb er")}

End With

'set command

Select Case InsertDeleteUpd ate

Case "Insert"

DAdapter.Inse rtCommand = CBuild.GetInser tCommand()

Case "Update"

DAdapter.Inse rtCommand = CBuild.GetUpdat eCommand()

Case "Delete"

DAdapter.Inse rtCommand = CBuild.GetDelet eCommand()

End Select

'use the Dataadapter.upd ate (Dataset,"Table ")

'use the ds.acceptchange s to

Dim returnit As New Returnit

returnit.DA = DAdapter

returnit.DS = DataSets

Return returnit

End Function




Nov 17 '06 #4
Warex wrote:
I am using the example from the microscuzz site on making a key but It keeps
giving me an error:

With DataSets.Tables ("Numbers")
.PrimaryKey = New DataColumn() {.Columns("Numb er")}
End With

Error:
Object reference not set to an instance of an object.
The Immediate Window is your friend.

Stick a break point on the above line and use the Immediate Window to
find out which of the objects is set to Nothing.

OK, you have to fully qualify each variable (you can't use access
..PrimaryKey directly any more) but you can still get there, with a bit
of digging.

Regards,
Phill W.
Nov 17 '06 #5
Thanks, I found the problem to your help,
Simply was a table declaration that was wrong while passing through
functions.
"Phill W." <p-.-a-.-w-a-r-d@o-p-e-n-.-a-c-.-u-kwrote in message
news:ej******** **@south.jnrs.j a.net...
Warex wrote:
>I am using the example from the microscuzz site on making a key but It
keeps giving me an error:

With DataSets.Tables ("Numbers")
.PrimaryKey = New DataColumn() {.Columns("Numb er")}
End With

Error:
Object reference not set to an instance of an object.

The Immediate Window is your friend.

Stick a break point on the above line and use the Immediate Window to find
out which of the objects is set to Nothing.

OK, you have to fully qualify each variable (you can't use access
.PrimaryKey directly any more) but you can still get there, with a bit of
digging.

Regards,
Phill W.

Nov 17 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
1359
by: EMW | last post by:
Hi, Could you please take a look and tell me what this means? Cor has tried to help me, but we haven't found it yet. Everytime I run this code, I get an exception error. Here is my code: Dim connStr As String = "Provider=Microsoft.JET.OLEDB.4.0;data source=" &
2
1416
by: Neeper | last post by:
I'm writing an application that displays a list of transactions from a mysql database. The problem I am having is I need the user to be able to view the last x transactions but there needs to be an initial row with the "balance forward" from the previous transactions. Is there any mysql statement for this or class for this type of feature or can point me in the right direction? TIA
0
980
by: news.microsoft.com | last post by:
first i apologize for the potential crosspost. this group gets far more traffic. now that i have that out of the way... ;) apparently using AutoGenerated Commands on Command objects does not work if you use a stored procedure or commandtext that contains one or more inner joins. im trying to implement a workaround that goes fine up to a particular step. I have a dataset that I bring to the client. This selectcommand statement contains...
4
2283
by: steroche | last post by:
I would REALLY appreciate help please please please! Im sure it is probably blindingly obvious to most of you but I am totally in the dark here!I am lost - i thought i had finally figured out this dataSet updating lark when i realised that i think i am right back at square 1!!! Here's my scenario - i have a SQLDB and i retrieve all my data from that into a dataset and display this to a datagrid(WebForm). I have got this grid sorted and...
10
27881
by: Bernie Yaeger | last post by:
I have a need to add a primary key to a dataset/datatable. How can this be done using a standard oledb data provider? Tx for any help.
9
3393
by: Steven C. | last post by:
Hello: I'm getting an error, "primary key not defined" when trying to use the FIND method on the DataTable Rows collection. I have a typed dataset called 'MortgagesDS' that I created with the XSL builder tool in .NET. I define the dataset at the beginning the the main class: MortgageDS _MortgageDS = new MortgageDS();
1
2018
by: GS | last post by:
set primary key option is greyed out in the dataset designer for a table Details In an vb.net express 2005 project, I have a dataset associated with table. lets call this table codetable. the dataset is an ms sql express mdf. in a different project, I use the vb studio data designer to change the codetable in the mdf. I set Primary Key first columns instead of just one. saved also changed the corresponding vsd file in designer.....
3
1339
by: iKiLL | last post by:
Hi all The Code is below but i will give you a brief over view first. I am using C#, SQL Mobile and the CF2.0 with Merge Replication. My Primary Keys are all "uniqueidentifier" types with default value of
1
1350
by: Rainer Queck | last post by:
Hello NG, I am using a typed DataSet, created with VS dataset designer. I have the problem , that a table in the dataset refuses to read a xml file. The strange thing is that if I create a seperate datatable, using the Typed DataSet.Table this reads the xml file without any problems: To make it a little more clear: public class MyClass {
0
996
by: nzkks | last post by:
Hi, I am trying the following SQL to fetch the needed data. The query works in query analyzer in SQL Server 2005. But in data adapter in a dataset in Visual Studio 2005, I am getting the data with all other empty cells. What mistake I am doing? The expected result is only a concatenated value (~/images/logos/Somelogo.jpg) SELECT (SELECT FilePath FROM dbo.FilePaths WHERE (FilePathID = dbo.Brands.BrandLogoImageFilePath)) + BrandLogoImageName AS...
0
10694
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10416
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10438
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9237
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6909
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5576
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5715
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4366
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3903
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.