Creating New User Issue in VB.net with SQL 2005:
I have a LogOn table and a Usr (User) table. A form that collects the new UserID,Password,FirstName,LastName, etc...
I want to have two separate INSERT statements to first insert the UserID & Password. Then grabs the LogOnSys just created and create a FK relationship for the next INSERT statement.
So I am looking for a statement to parse out the LogOnSys from strSqlSmt2:
strSqlStmt = "INSERT LogOn (UserID,Password)" & _ "VALUES ('" & pobjCreateTech.UsrName & "', '" & pobjCreateTech.Password & "')" strSqlStmt2 = "SELECT LogOnSys FROM LogOn WHERE UserID = ' " & pobjCreateTech.UsrName & "')" 'Convert SQL Statement from string to integer? 'intLogOnSys = strSqlStmt2 strSqlStmt3 = "INSERT Tech (FstNam,LstNam,Title,Email,Phn,LogOnSys) " & _ "VALUES ('" & pobjCreateTech.FirstName & "', '"[/COLOR] & _ pobjCreateTech.LastName & "','" & pobjCreateTech.Title & _ "','" & pobjCreateTech.Email & "','" & pobjCreateTech.Phone & "','" & intLogOnSys & "')" objSqlCmd = New SqlCommand 'instancating sqlCommand objSqlCmd.Connection = objSqlConn objSqlCmd.CommandText = strSqlStmt & strSqlStmt2 & strSqlStmt3 objSqlCmd.CommandType = CommandType.Text
Thanks for any help at all!!! and sorry for making the question so long, I just wanted to make sure people understood my question. :) Also, if there is a lot easier way of doing this... PLEASE tell me. :D
Edited 4 Years Ago by pyTony: fixed formatting