Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input is constantly recognized as Null

Status
Not open for further replies.

Mike555

Technical User
Feb 21, 2003
1,200
US
After posting this in the ASP.NET forum (thread855-941738) I realized that it would be better suited here since it is actually a VB.NET question.

I'm programming a sub that adds a new record to a database. On my form I have an "Add" button with the below click handler.

The process is pretty straight forward - I simply populate 3 textboxes ('FlitchNum' being the PK), click this button and the new record should be created.


Code:
    Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click

        Dim log As New LogsDP
        Dim logrow As DsLogs.spLogsSelectRow

        logrow = DsLogs1.spLogsSelect.NewRow

        logrow.FlitchNum = Me.txtFlitchNum.Text
        logrow.WhoOrdered = Me.txtWhoOrdered.Text
        logrow.VendorName = Me.txtVendor.Text

        log.AddLog(logrow)

        Response.Redirect("Logs_List.aspx")

    End Sub

However, when I run this I'm getting the error:
Column 'FlitchNum' does not allow nulls.

The error also shows that the following code, which is located in my dataset's .vb file, is causing the problem.

Line 425:
Line 426: Public Overloads Sub AddspLogsSelectRow(ByVal row As spLogsSelectRow)
Line 427: Me.Rows.Add(row)
Line 428: End Sub
Line 429:

Using a Breakpoint and a Watch I've verified that the textbox values are being passed correctly. The error occurs after they are passed.

Could someone please help me understand why this error is occuring? Thanks.

--
Mike
 
not that I pretend to even understand a bit of what youre code is doing. but in windowsforms we need to do something like this before saving the dataset or updating the dataadapter via datatadapter.update(dataset)

me.bindingcontext(datasetname).endcurrentedit.

just my 2 cents.

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Your DataSet does not know that there is an AutoIncrement field (I suppose you are using one). Look up "FillSchema()" in help.
 
RiverGuy, Actually the PK column is not an AutoIncrement. The user must input a value with each new record. Thanks.

--
Mike
 
Well, try explicitly casting your .Text to a numeric datatype.
 
I wish I could say that worked but it didn't. I'm stumpted on this one. Thanks for your help.

--
Mike
 
Check what the values of row.Items(0-2) are on line 427

That's the last place you should be able to see the data before it gets saved, so if it's correct there, then I'd guess it would be some sort of driver issue.

-Rick

----------------------
 
You could also check if you have declared a variable elsewhere called 'row'. If so, the code 'me.rows.add(row)' may be using that rather than the parameter passed to the sub.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top