Click here to Skip to main content
15,908,906 members
Home / Discussions / Database
   

Database

 
GeneralRe: alternative to rewire CASE WHEN in query Pin
prachidalwadi3-Aug-10 19:36
prachidalwadi3-Aug-10 19:36 
GeneralRe: alternative to rewire CASE WHEN in query Pin
Herman<T>.Instance28-Jul-10 3:38
Herman<T>.Instance28-Jul-10 3:38 
AnswerRe: alternative to rewire CASE WHEN in query Pin
PIEBALDconsult26-Jul-10 8:05
mvePIEBALDconsult26-Jul-10 8:05 
AnswerRe: alternative to rewire CASE WHEN in query Pin
Jörgen Andersson27-Jul-10 21:31
professionalJörgen Andersson27-Jul-10 21:31 
QuestionMessage Removed Pin
25-Jul-10 1:24
bapu288925-Jul-10 1:24 
AnswerRe: SQL INSERT ISSUE Pin
Matt U.25-Jul-10 6:23
Matt U.25-Jul-10 6:23 
AnswerRe: SQL INSERT ISSUE Pin
Stoffy197225-Jul-10 7:13
Stoffy197225-Jul-10 7:13 
QuestionRe: SQL INSERT ISSUE Pin
bapu288925-Jul-10 21:15
bapu288925-Jul-10 21:15 
hello sir
thanks for ur rep.
and i dont know that i have shouted on any body
this is what i have done so far but no luck.

this is 2 different sp

ALTER PROCEDURE dbo.NewInsertCommand
(
	@City nvarchar(50),
	@State nvarchar(50)
)
AS
	SET NOCOUNT ON;
	
	DECLARE @LocationID int;
INSERT INTO [Location] (City,State)
		VALUES (@City, @State)

SELECT @LocationID = SCOPE_IDENTITY()

this is the second one

ALTER PROCEDURE dbo.InsertUser 

	@FirstName varchar(25),
	@LastName varchar(25),
	@LocationID int
	
AS
	
	INSERT INTO [UserData] (LocationID, FirstName, LastName)
(SELECT @LocationID, @FirstName, @LastName)
	
	
	RETURN


and this is the vb


Private Sub AddNewNames()
        FirstNameArray.Add(FirstName.Text)
        FirstNameArray.ToArray()
        LastNameArray.Add(LastName.Text)
        LastNameArray.ToArray()
    End Sub

 Private Sub InsertData()

        Try
            Dim Flag As Boolean = False
            'GetDBConnection()
            Dim cmd As New SqlCommand("NewInsertCommand", LetsGo.GetDBConnection)
            cmd.CommandType = CommandType.StoredProcedure
            cmd.Parameters.Add("@City", SqlDbType.NVarChar).Value = ComboBox1.SelectedItem
            cmd.Parameters.Add("@State", SqlDbType.NVarChar).Value = ComboBox2.SelectedItem
            cmd.ExecuteNonQuery()

            cmd = New SqlCommand("InsertUser", LetsGo.GetDBConnection)
            cmd.CommandType = CommandType.StoredProcedure
            For I As Integer = 0 To FirstNameArray.Count - 1
                cmd.Parameters.Add("@FirstName", SqlDbType.NVarChar).Value = FirstNameArray(I).ToString
                cmd.Parameters.Add("@LastName", SqlDbType.NVarChar).Value = LastNameArray(I).ToString
                cmd.ExecuteNonQuery()
            Next

            MsgBox("Data Saved Successfully !", MsgBoxStyle.Information)

and one more thing i dont know how to get @LocationID from one sp to another sp as well
so would you mind to guide me please

waiting for your kind help
thanks
AnswerRe: SQL INSERT ISSUE Pin
PIEBALDconsult26-Jul-10 8:24
mvePIEBALDconsult26-Jul-10 8:24 
AnswerRe: SQL INSERT ISSUE Pin
Stoffy197226-Jul-10 8:35
Stoffy197226-Jul-10 8:35 
GeneralRe: SQL INSERT ISSUE Pin
bapu288926-Jul-10 21:23
bapu288926-Jul-10 21:23 
AnswerHow to ask a question Pin
Luc Pattyn26-Jul-10 23:34
sitebuilderLuc Pattyn26-Jul-10 23:34 
QuestionInstall SQL 2008 r2 express with my application Pin
bonzaiholding24-Jul-10 22:29
bonzaiholding24-Jul-10 22:29 
AnswerRe: Install SQL 2008 r2 express with my application Repost Pin
Richard MacCutchan25-Jul-10 1:40
mveRichard MacCutchan25-Jul-10 1:40 
Answercross-post Pin
Luc Pattyn25-Jul-10 2:18
sitebuilderLuc Pattyn25-Jul-10 2:18 
Question[MS SQL SERVER] Create constraints in a cyclic relations Pin
Lutosław23-Jul-10 23:32
Lutosław23-Jul-10 23:32 
Questionanother query Pin
reza assar23-Jul-10 21:40
reza assar23-Jul-10 21:40 
AnswerRe: another query Pin
Goutam Patra23-Jul-10 22:58
professionalGoutam Patra23-Jul-10 22:58 
GeneralRe: another query Pin
reza assar24-Jul-10 1:03
reza assar24-Jul-10 1:03 
Questionquery Pin
reza assar23-Jul-10 21:32
reza assar23-Jul-10 21:32 
AnswerRe: query Pin
Goutam Patra23-Jul-10 22:57
professionalGoutam Patra23-Jul-10 22:57 
AnswerRe: query Pin
Mycroft Holmes23-Jul-10 23:05
professionalMycroft Holmes23-Jul-10 23:05 
QuestionMessage Removed Pin
23-Jul-10 21:06
prachidalwadi23-Jul-10 21:06 
AnswerRe: How to optimize the query with more than one left outer join Pin
CitrusTech23-Jul-10 21:14
CitrusTech23-Jul-10 21:14 
Questionsql problem Pin
bapu288923-Jul-10 20:40
bapu288923-Jul-10 20:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.