|
-
May 28th, 2004, 06:33 AM
#1
Thread Starter
Junior Member
Generic SQL and .NET help [RESOLVED]
Heyas!
Did the usual searching...couldn't come up with anything...
I'm new to .NET, but have a good grasp of VB6.
Anyway, I'm sure I have a configuration error, but I can't figure out where. Seems like .NET is much more strict about having your program setup the exact way it wants...
Ok, I have a simple Windows app that is trying to read and write to a SQL Server on the company network.
I'm using an OleDb dataadapter and connection. (Never could get the SQL data components working...). I don't get any errors when I create the components through the wizard, everything looks good.
I can also read the SQL Server table and dump it all in the dataadapter/dataset without issue.
As far as writing, I can't update any of the fields in a given row if that row has null values in it. Even if the field I'm dealing with doesn't have a null, as long as there is a null somewhere in the row it throws an error. I set the data adapter to update on error anyway (not caring about the other fields) but of course it doesn't do anything but move on.
In any case, I'm sure this is a configuration error with my data adapter or some other property I need to set. I've looked everywhere, including my numerous books, but can't seem to hit on the right search string to find my answer.
Thanks for any help!
Last edited by Dador; May 28th, 2004 at 01:14 PM.
-
May 28th, 2004, 07:59 AM
#2
Hyperactive Member
If I could see your code, I could probably help
-
May 28th, 2004, 08:42 AM
#3
Check the table definition. Does the columns allow NULL values? If the col is defined with a NOT NULL clause it means that it cannot accept NULL and the whole row will be rejected.
This is what it sounds like to me.
TG
-
May 28th, 2004, 10:15 AM
#4
Thread Starter
Junior Member
Ok, here's some code I knocked up for testing...
Also, the table does allow for nulls, as some fields can and need to be empty during different times.
VB Code:
'clear the dataset
dsTape.Clear()
'dim sql variable for clean code, set strVirtualTable also for
'clean code - not really necessary but reminds me it is a virtual table
Dim strSQL As String
strVirtualTable = "Tape"
'grab the whole data row of the user inputed tape number
strSQL = "SELECT * FROM dbo.UtilityTapeData " & _
"WHERE [Tape_Number] = '" & intTapeNumber & "'"
'setup the dataset and get the sql statement from above
daTape.FillSchema(dsTape, SchemaType.Source, strVirtualTable)
daTape.SelectCommand.CommandText = strSQL
daTape.Fill(dsTape, strVirtualTable)
'test area, just try to throw some info into the comments field
Dim objRow As DataRow
objRow = dsTape.Tables(strVirtualTable).Rows.Find(intTapeNumber)
objRow.Item("Comments") = "4444"
daTape.Update(dsTape, strVirtualTable)
Thanks for taking a look fellas!
Last edited by Dador; May 28th, 2004 at 10:18 AM.
-
May 28th, 2004, 01:17 PM
#5
Thread Starter
Junior Member
Ok fellas, figured it out...sorta.
There was some problem with the dataset. Apparently, I generated the dataset back when I had the database setup to NOT allow nulls. Therefore, the dataset grabbed that mapping apparently. So, after I changed the database to allow nulls, the dataset didn't update itself.
I had to search around in the .xsd file to find tha attribute for the dataset that showed it wouldn't accept a null. Unfortunately, I couldn't change it from there.
So, I deleted it and generated a new dataset. All is well.
Thanks for the help everyone.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|