Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27248

VS 2012 How to retrieve the autoassigned value for a customer record from a table adapter

$
0
0
Hi again everyone.

I'm trying to create new users depending on 2 tables (Customer and Login), so when I click a Register Button it executes the following code:

Code:

If (txtName.Text = String.Empty And txtSurname.Text = String.Empty) Then
            MessageBox.Show("")
        ElseIf txtName.Text = String.Empty Then
            MessageBox.Show("")
        ElseIf txtSurname.Text = String.Empty Then
            MessageBox.Show("")
        ElseIf txtUsername.Text = String.Empty And txtPassword.Text = String.Empty Then
            MessageBox.Show("")
        ElseIf txtSurname.Text = String.Empty Then
            MessageBox.Show("")
        ElseIf txtPassword.Text = String.Empty Then
            MessageBox.Show("")
        Else
            Dim taCustomer As New File_Storage_Manager_DBDataSetTableAdapters.CustomerTableAdapter
            Dim taLogin As New File_Storage_Manager_DBDataSetTableAdapters.LoginTableAdapter
            taCustomer.InsertQueryCustomer(txtName.Text, txtSurname.Text, txtAge.Text, txtAddress.Text, mTxtZipCode.Text)
            taLogin.InsertQueryLogin(txtUsername.Text, txtPassword.Text)
       
        End If

Note: The red marked lines are the queries I'm using (via Stored Procedures), the 1st one works fine, as I'm guessing it's because it has no dependencies, but the 2nd insert doesn't do anything at all, not even an error, it just returns 0 rows inserted. So, my best guess would be that the Insert statement is wrong.

Here's the Stored Procedure for the 2nd query (InsertQueryLogin):

Code:

ALTER PROCEDURE [dbo].InsertQueryTest
(
        @ID_User nvarchar(50),
        @Password nvarchar(50)
)
AS
        SET NOCOUNT OFF;
INSERT INTO        Login
                                      (ID_User, Password, Cod_Customer)
SELECT                      L.ID_User, L.Password, L.Cod_Customer
FROM                        Login AS L INNER JOIN
                                      Customer AS Cust ON L.Cod_Customer = Cust.Cod_Customer
WHERE                      (L.ID_User = @ID_User) AND (L.Password = @Password)

Can anyone point out what's wrong?

Viewing all articles
Browse latest Browse all 27248


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>