I am trying to get the questionID from two different Select statements and then insert into a table one by one. DECLARE @NewID INT This one is inserting a new surveyID, Output is SurveyID insert into survey(title,description, surveystatus,CreatedBy,date ) values('New Survey','New Survey',1,'test',Getdate()) SELECT @NewID = SCOPE_IDENTITY() Copying the questions with the new surveyID INSERT SurveyQuestions(surveyid, questions,answertype) SELECT @NewID ,questions,answertype FROM SurveyQuestions WHERE surveyid='81' The problem is below here. I want to get the value of the questionId of the first select statement then the value of the questionID of the second select statement and insert into the table SurveyChoices one by one. Both the select statements can have 1 or 2 or 3 rows or more but the both the select statements will have exact number of rows. select QuestionId from surveyquestions where surveyid=@NewID and answertype <> 'T' select QuestionId from surveyquestions where surveyid='81' and answertype <> 'T' Here i am using the insert statement using the value form First select statement and second select statement INSERT Surveychoices(QuestionId,choice) SELECT questionID,choice((This is the value of the First select statement.) FROM Surveychoices WHERE questionid=questionID(This is the value of the second select statement.)
soorma
Posts
-
Help with this Stored proc -
cache question on a webserviceI need to cache the results when this web method is called. It is a web service. here is the code WebMethod _ Public Function something() As String() Return _some.GetTesttFieldValues(_Groups.GetTestName("Something").Id, "Field3") End Function GetTesttFieldValues is a function. Public Function GetTesttFieldValues(ByVal SomeId As Integer, ByVal SomeName As String) As IEnumerable(Of String) Implements ISome.GetTesttFieldValues Dim query As New Query() query.SomeId = SomeId Dim documents As DocumentCollection = GetDocuments(query) Return (From d As Document In documents Select CType(GetType(Document).GetProperty(fieldName).GetValue(d, Nothing), String)).Distinct().ToArray() end function
-
displaying controls [modified]I have a datareader and i am passing many strings one by one to a sub. I think i have to do dynamically but how can i do it. The data looks like this datetimestart datetimeend String String cboStringM i don't know the data in adv.. i am looping thru one by one. i don't know how many strings i will encounter. i can encounter 3 or 4 or 1 but i need to display the textbox for each string i pass and same goes for the listbox. When i pass the datetimestart i show the calendar control. When i pass the datetimeend i show another calendar control. When i pass the String i show the textbox. When i pass the second String i show another textbox. when cboStringM then a listbox But the second textbox is not showing. When the first string is passed the firsttextbox is set to true when when the second strings turn comes the firsttextbox is already true and it doesn't go to the second one. That is my problem. How can i show both the textboxes when 2 strings are passed of the same name. here is the code Dim ParameterReportType As New Data.SqlClient.SqlParameter("@id", SqlDbType.VarChar, 50) ParameterReportType.Value = Request.QueryString("id") myCommandReportType.Parameters.Add(ParameterReport Type) Dim objReaderparam As SqlDataReader = myCommandReportType.ExecuteReader() Dim DisplayedName As New ArrayList Dim ParameterType As New ArrayList Dim ParameterName As New ArrayList Dim DataSource As New ArrayList Dim Hidden As New ArrayList Dim DefaultValue As New ArrayList Dim DatabaseSourceNumber As New ArrayList While objReaderparam.Read() DisplayedName.Add(objReaderparam.Item("DisplayedNa me")) ParameterType.Add(objReaderparam.Item("Parameterty pe")) ParameterName.Add(objReaderparam.Item("ParameterNa me")) DataSource.Add(objReaderparam.Item("DataSource")) Hidden.Add(objReaderparam.Item("Hidden")) DefaultValue.Add(objReaderparam.Item("DefaultValue ")) DatabaseSourceNumber.Add(objReaderparam.Item("Data baseSourceNumber")) formattable(objReaderparam.Item("DisplayedName"), (objReaderparam.Item("Parametertype")), (objReaderparam.Item("ParameterName")), (objReaderparam.Item("DataSource")), (objReaderparam.Item("Hidden")), (objReaderparam.Item("DefaultValue")), (objReaderparam.Item("DatabaseSourceNumber"))) End While objReaderparam.Close() Sub formattable(ByVal DisplayedName As String, ByVal Parametertype As String, ByVal ParameterName As String, ByVal DataSource As String, ByVal Hidden As String, ByVal DefaultValue As String, ByVal DatabaseSourceNumber As String)
-
File system objectI have a text file and i want to Split the file into mulitple files based off the city and then create new files with the city name. I am able to read the file and also chnaged the semi colon to a comma in the file. How do i split into multiple files based on city and then create new ones based upon city names This is how the text file looks like(just a junk data) FirstName;LastName;DOB;City;State;Zip Suzy;Adams;05/15/1977;Salt Lake City;UT;84054 Brady;Broom;03/16/1978;Provo;UT;84054 Andrew;Packard;02/06/1980;Salt Lake City;UT;84034 Ralph;Vunderly;01/15/1983;Provo;UT;84023 Thi si my code looks like Imports System Imports System.IO Imports System.Collections Partial Class _Default Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim objReader As New StreamReader("c:\test.txt") Dim sLine As String = "" Dim arrText As New ArrayList() Do sLine = objReader.ReadLine() If Not sLine Is Nothing Then sLine = Replace(sLine, ";", ",") arrText.Add(sLine) End If Loop Until sLine Is Nothing objReader.Close() For Each sLine In arrText ' Console.WriteLine(sLine) ' MsgBox(sLine) 'Response.Write(sLine) Dim furst As String = arrText(0) Response.Write(furst) Next 'Response.Write(sLine) Response.Write(furst) Console.ReadLine() End Sub End Class