Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SQL 2014 and VB 2015

Posted on 2016-07-24
4
Medium Priority
?
80 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 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

885 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