Solved

SQL 2014 and VB 2015

Posted on 2016-07-24
4
45 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
  • 3
4 Comments
 
LVL 142

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now