Solved

SQL 2014 and VB 2015

Posted on 2016-07-24
4
62 Views
Last Modified: 2016-07-24
I have a windows form that is connected to a SQL 2014 dataset. I just recently upsized the form from a  local access table to a SQL server table. OH BOY!

A left over issue that I'm having is that I have a PK set on field called 'Record_ID' that is seeded from the server. The update command is throwing an error that the value is null. (that's my problem I think) The identical code worked fine for Access by SQL is wielding amighty fist I think (which is why I did it)

I'm using this code.
Company_ContactsBindingSource.EndEdit()
Company_ContactsTableAdapter1.Update(Me.DB_104222_crmDataSet.Company_Contacts)

I'm left wondering if I can insert new and call an update to force the field to update and assign a value? The  continue to add any information and update again?

Ideas?
0
Comment
Question by:SchoolTeacher54
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 41726730
make the field identity, that should do it.
0
 

Author Comment

by:SchoolTeacher54
ID: 41726782
I set it to identity but...

When I call the update I get a message back saying that "the field doesn't allow nulls"; which is true because it is an identity.

When I call add new I'm thinking that I need to update that record to pull that value? I think that but I'm not sure how to do that.
0
 

Assisted Solution

by:SchoolTeacher54
SchoolTeacher54 earned 0 total points
ID: 41726811
Oh boy again!

I mentioned that I moved the database from Access to SQL . Everything went fairly well except for this problem.

It turns out that even though the message sent back from .net said that the 'identity value' cannot be null, that message had nothing to do with the problem. It turns out that 7 fields in this table had the allow null checkbox value turned off. Sql Server didn't like that values being null so it in turn pulled 'identity value' out of it's hat and gave me that message.

Epitome of the 'red herring'. In the end got it figured out and I'm adding this up to a gotcha and 'served me right' for not developing the app in SQL to begin with!
0
 

Author Closing Comment

by:SchoolTeacher54
ID: 41726812
Thanks for checking in Guy!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question