Solved

SQL 2014 and VB 2015

Posted on 2016-07-24
4
51 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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
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.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

911 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