Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQL 2014 and VB 2015

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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
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…
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

718 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