One Form To Update Different SQL Tables Based Upon Form Selection

Apr 16, 2008

Hello,

My company Intranet has a form that agents can use to post their comments about the company to upper management, but our customer service department would like to modify the form so that the agent has to pick from a comment type.

The dropdown options on the form will be as follows:

Compliments
Complaints
General Comments
Suggestions

Each dropdown option has a designated table in a SQL DB.
Using postback on the same page, I need to change which fields of the form are visible based upon which dropdown selection the user chooses, and I need the fields to then be inserted into the table that corresponds with the dropdown selection item.

For example: If the Compliments dropdown selection is picked, I need a text box to show for the user's location, the name of the customer, account number, and the message box. Once the submit button is clicked, the characters in these boxes need to be inserted into the Compliments table using its data adapter.

However, if the user selects Suggestions, the name of the customer and the account number should not be visible, since these fields do not exist and when the submit button is pressed, the Suggestions table should be updated.

If you need more information, I will provide whatever is needed.

As always, thanks for everyone's assistance.

Chris

View 3 Replies


ADVERTISEMENT

Depending On The Selection Of The User Of The Asp.net Web-form How Can I Do Changes In The Stored Procedure

May 11, 2007

Hi frdz,  I have created the following stored procedure in sql server 2005. In my database i have one option for the payment mode which can be done thru cash or credit(cheque).   I have created my web-application in asp.net with C# 2005. There i have a dropdownlist box for the user to select the option whether wants to do the payment thru cash or cheque.Depending on that selection if user selects cheque then all the reqt for cheque like it's no,dt,bankname etc...are visible.but if user selects the option as cash then the cheque details become invisible.Depending on the selection of the user of the asp.net web-form how can i do changes in the stored procedure...   i can write the condition likeif paymentmode=cash then ..........else.............but where and how can it be written ...pls tell methanxs in adv...u can go thru my below SP     ALTER PROCEDURE MiscellaneousStoredProcedure


@miscid int output,
@storename varchar(20),--store name to storeid
@accountname varchar(20),
@groupname varchar(20),
@paymentdt datetime,
@payeename varchar(30),
@paymode varchar(20),
@bankname varchar(50),
@chqdt datetime,
@chqno varchar(20),
@amt numeric(10, 2),
@bal numeric(10, 2),
@remarks varchar(50)

as

declare

@storeid int,
@accountid int,
@groupid int



begin
set nocount on
select @miscid = isnull(max(@miscid),0) + 1 from miscellaneourpay

if exists (select * from storemaster where storename = @storename)
select @storeid = storeid from storemaster where storename = @storename

if exists (select * from accountmaster where accountname =@accountname)
select @accountid = accountid from accountmaster where accountname =@accountname

if exists (select * from accountgroupmaster where groupname=@groupname)
select @groupid=groupid from accountgroupmaster where groupname=@groupname




begin transaction
insert into miscellaneourpay
(
miscid,
storeid,
accountid,
groupid,
paymentdt,
paymode,
payeename,
bankname,
chqdt,
chqno,
amt,
bal,
remarks

)
values
(

@miscid,
@storeid,
@accountid,
@groupid,
@paymentdt,
@paymode,
@payeename,
@bankname,
@chqdt,
@chqno,
@amt,
@bal,
@remarks

)
commit transaction

end 

View 2 Replies View Related

How To Make The SSMSE To Return Whole Records Without Any Close Query Form And Re-create Query Form Operation?

Dec 25, 2007

Hi,
I got a problem.
I installed Microsoft SQL Server Management Studio Express 2005 version.
And I created a Compact database.
I created an connection in SSMSE to connect the database and opened a query form.
then, i run the following sql:

Select * from Table1

It returned 3 records to me.
After that, I used program to insert record into this table.
Then i ran this sql again, it still show me 3 records.
I closed the query form, and re-created a new query form, then run the sql, it returned 4 records to me.

Why? It's very strange and difficult to operate, right?
Is there anyone know how to make the SSMSE to return whole records without any close query form and re-create query form operation?

Thanks a lot!

And Merry X'max!!!

View 4 Replies View Related

First Form Normalizations And Second Form Normalization

Jul 19, 2006

Hi everyone,
What is the main difference between first form normalizations and second form normalization ?
In my opinion, they are both generated for the same operation which is to prevent redundancy(in other words; duplication of data in several records).
So would you please explain it to me ?

Thanks

View 1 Replies View Related

What Is The Best Way To Build The Search Based On Form Fields

Oct 5, 2007

I required to build the search feature for my application which contains combination of at least 20 search fields e.g firstname, lastname. date of birth, sign up date ,etc... I am just wondering what is the best way to do it ,should I create stored procedure with 20 input parameters or should I build it based on each search fields. I need to provide the search results via web services. Could anyone help me?
Thank you

View 5 Replies View Related

Can Create Access Form Layout Based On Table From Sql?

Sep 25, 2006

Hi,

Can this be done? Please advise. Thanks.Is there any template available in sql for creating forms?

View 1 Replies View Related

Form Based Authentication + Webform Report Viewer Control

Nov 19, 2007



Hi,
I would like to know how to call a report from a report viewer control in a web application. The reporting services is forms authenticated. I've done this authentication using the sample solution given by microsoft (adding custom security extension). Now am able to view the reports from Report manager and Report server URL. But i dont know how to authenticate the user from my web application and pass the credentials to the report server to view the report in report viewer control. Can somebody help in this? its bit urgent. Thanks in advance

View 1 Replies View Related

Update Web Form

Dec 29, 2005

I'm trying to create a online update form to a SQL table. I've neverdone this function before, and I'm not quite sure I have the codingcorrect. Below is the coding for the Update statement.final String udc = "UPDATE INTO " + "Comm_WebSubmission Set ProjectID= request.getParameter("ProjectID")(Assigned,DateAssigned,Status,StatusDescription,Re solution,CompletionDate)values(?,?,?,?,?,?)";Any help you can give me would be greatly appreciated.Cat

View 1 Replies View Related

Form Update Problem

Jan 8, 2008

I'm very new to asp.net and c#, I have been thrown in the deep end with a project at work and I'm really struggling to overcome this problem so any help will be very greatly appreciated.  I have a form with a number of textboxes that users use to update records in a database table with the use of a stored procedure.  The problem is that I can't get the form to just update the boxes that a user has filled out.  The form is working at the moment only if the user fills out all the boxes on the form which obviously is a waste of time if they only want to update one field.  I have tested the stored procedure and it works fine.  Please find the below code I'm trying to use!
 1 protected void Targets_Insert(object sender, EventArgs e)
2 {
3 System.Data.SqlClient.SqlConnection objConn = new System.Data.SqlClient.SqlConnection();
4 objConn.ConnectionString = "Data Source=SQL1;Password=rdbx;User ID=rdbx;Initial Catalog=Pronet";
5 objConn.Open();
6 System.Data.SqlClient.SqlCommand objCmd = new System.Data.SqlClient.SqlCommand("Update_Targets", objConn);
7 objCmd.CommandType = System.Data.CommandType.StoredProcedure;
8
9 System.Data.SqlClient.SqlParameter pdate = objCmd.Parameters.Add("@date", System.Data.SqlDbType.DateTime);
10 System.Data.SqlClient.SqlParameter pcontacts_new = objCmd.Parameters.Add("@contacts_new", System.Data.SqlDbType.Int);
11 System.Data.SqlClient.SqlParameter papplicants_new = objCmd.Parameters.Add("@applicants_new", System.Data.SqlDbType.Int);
12 System.Data.SqlClient.SqlParameter pclients_new = objCmd.Parameters.Add("@clients_new", System.Data.SqlDbType.Int);
13 System.Data.SqlClient.SqlParameter pHeadhunts_new = objCmd.Parameters.Add("@headhunts_new", System.Data.SqlDbType.Int);
14 System.Data.SqlClient.SqlParameter pCanvass_Calls_new = objCmd.Parameters.Add("@canvass_Calls_new", System.Data.SqlDbType.Int);
15 System.Data.SqlClient.SqlParameter pRegens_new = objCmd.Parameters.Add("@regens_new", System.Data.SqlDbType.Int);
16 System.Data.SqlClient.SqlParameter pJobs_Added_new = objCmd.Parameters.Add("@jobs_added_new", System.Data.SqlDbType.Int);
17 System.Data.SqlClient.SqlParameter pCVS_sent_new = objCmd.Parameters.Add("@CVS_sent_new", System.Data.SqlDbType.Int);
18 System.Data.SqlClient.SqlParameter puserid = objCmd.Parameters.Add("@userid", System.Data.SqlDbType.Int);
19 System.Data.SqlClient.SqlParameter punique_applicants_sent_new= objCmd.Parameters.Add("@unique_applicants_sent_new", System.Data.SqlDbType.Int);
20 System.Data.SqlClient.SqlParameter paverage_rate_new = objCmd.Parameters.Add("@average_rate_new", System.Data.SqlDbType.Int);
21 System.Data.SqlClient.SqlParameter paverage_salary_new = objCmd.Parameters.Add("@average_salary_new", System.Data.SqlDbType.Int);
22 System.Data.SqlClient.SqlParameter paverage_fee_new = objCmd.Parameters.Add("@average_fee_new", System.Data.SqlDbType.Int);
23 System.Data.SqlClient.SqlParameter pdeals_new = objCmd.Parameters.Add("@deals_new", System.Data.SqlDbType.Int);
24 System.Data.SqlClient.SqlParameter poffers_new = objCmd.Parameters.Add("@offers_new", System.Data.SqlDbType.Int);
25 System.Data.SqlClient.SqlParameter pinterviews_taken_place_new = objCmd.Parameters.Add("@interviews_taken_place_new", System.Data.SqlDbType.Int);
26 System.Data.SqlClient.SqlParameter pinterviews_arranged_new = objCmd.Parameters.Add("@interviews_arranged_new", System.Data.SqlDbType.Int);
27 System.Data.SqlClient.SqlParameter punique_mailshots_sent_new = objCmd.Parameters.Add("@unique_mailshots_sent_new", System.Data.SqlDbType.Int);
28 System.Data.SqlClient.SqlParameter pmailshots_new = objCmd.Parameters.Add("@mailshots_new", System.Data.SqlDbType.Int);
29 puserid.Value = Convert.ToInt16(userid.Text);
30 pdate.Value = Convert.ToDateTime(date.Text);
31
32 objCmd.ExecuteNonQuery();
33 objConn.Close();
34

 
Thanks in a dvance
 
Dave

View 4 Replies View Related

Problems With SQL And Update From Form

Jun 19, 2008

I am trying to upgrade my site from Microsoft Access to SQL and it runs fine except when I try do the update from the webform. BElow is my code. If someone can see why it is happening that would be great:
 The error I get is: Line 1: Incorrect syntax near 'nvarchar'.
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="HIGHWAY" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
&nbsp;<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NCCAUTHConnectionString %>"
DeleteCommand="DELETE FROM [TblMain] WHERE [ID] = @ID" InsertCommand="INSERT INTO [TblMain] ([ID], [Auth No], [Caller], [Date], [Time], [H S No], [Type], [Contractor], [Origin], [Destination], [Modification Requested], [Trailer Number], [Pull Date], [Pull Time], [Contractor Date], [Contractor Time], [CDO], [Message Number and comments]) VALUES (@ID, @Auth_No, @Caller, @Date, @Time, @H_S_No, @Type, @Contractor, @Origin, @Destination, @Modification_Requested, @Trailer_Number, @Pull_Date, @Pull_Time, @Contractor_Date, @Contractor_Time, @CDO, @Message_Number_and_comments)"
SelectCommand="SELECT * FROM [TblMain]" UpdateCommand="UPDATE [TblMain] SET [Auth No] = @Auth_No, [Caller] = @Caller, [Date] = @Date, [Time] = @Time, [H S No] = @H_S_No, [Type] = @Type, [Contractor] = @Contractor, [Origin] = @Origin, [Destination] = @Destination, [Modification Requested] = @Modification_Requested, [Trailer Number] = @Trailer_Number, [Pull Date] = @Pull_Date, [Pull Time] = @Pull_Time, [Contractor Date] = @Contractor_Date, [Contractor Time] = @Contractor_Time, [CDO] = @CDO, [Message Number and comments] = @Message_Number_and_comments WHERE [ID] = @ID">
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Auth_No" Type="String" />
<asp:Parameter Name="Caller" Type="String" />
<asp:Parameter Name="Date" Type="String" />
<asp:Parameter Name="Time" Type="String" />
<asp:Parameter Name="H_S_No" Type="String" />
<asp:Parameter Name="Type" Type="String" />
<asp:Parameter Name="Contractor" Type="String" />
<asp:Parameter Name="Origin" Type="String" />
<asp:Parameter Name="Destination" Type="String" />
<asp:Parameter Name="Modification_Requested" Type="String" />
<asp:Parameter Name="Trailer_Number" Type="String" />
<asp:Parameter Name="Pull_Date" Type="String" />
<asp:Parameter Name="Pull_Time" Type="String" />
<asp:Parameter Name="Contractor_Date" Type="String" />
<asp:Parameter Name="Contractor_Time" Type="String" />
<asp:Parameter Name="CDO" Type="String" />
<asp:Parameter Name="Message_Number_and_comments" Type="String" />
<asp:Parameter Name="ID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="ID" Type="Int32" />
<asp:Parameter Name="Auth_No" Type="String" />
<asp:Parameter Name="Caller" Type="String" />
<asp:Parameter Name="Date" Type="String" />
<asp:Parameter Name="Time" Type="String" />
<asp:Parameter Name="H_S_No" Type="String" />
<asp:Parameter Name="Type" Type="String" />
<asp:Parameter Name="Contractor" Type="String" />
<asp:Parameter Name="Origin" Type="String" />
<asp:Parameter Name="Destination" Type="String" />
<asp:Parameter Name="Modification_Requested" Type="String" />
<asp:Parameter Name="Trailer_Number" Type="String" />
<asp:Parameter Name="Pull_Date" Type="String" />
<asp:Parameter Name="Pull_Time" Type="String" />
<asp:Parameter Name="Contractor_Date" Type="String" />
<asp:Parameter Name="Contractor_Time" Type="String" />
<asp:Parameter Name="CDO" Type="String" />
<asp:Parameter Name="Message_Number_and_comments" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
<asp:Button ID="Button1" runat="server" PostBackUrl="~/Test.aspx" Text="Add New Authorization" />
<asp:GridView ID="GridView1" runat="server" CellPadding="3" DataSourceID="SqlDataSource1" GridLines="Vertical"
Style="font-size: 8pt; font-family: Arial" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" Font-Bold="True" AllowSorting="True">
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<Columns>
<asp:CommandField ShowEditButton="True" />
</Columns>
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="Gainsboro" /></asp:GridView>
</asp:Content>

View 4 Replies View Related

How Do I Bring In A Date Which Is In Integar Form Into A Databse As A Date Form.

Jul 23, 2005

HiI have a Platinum database which stores dates in integer form e.g the dateis formatted as below:Column_name Type Length Precision------------------------------ ------------------------------from_date int 4 10Some of the dates in the Platinum database are as follows:729115729359730059730241730302730455How can I bring them into SQL 2000 as valid dates.Thanks for your assistanceSam CJoin Bytes!

View 1 Replies View Related

Unable To Update SQL Table From A Web Form

Jan 20, 2006

I have a Table which stores data from two different databases. To update it I made a Web Form that opens a single record where you can edit the data (using TextBox). Then there is an Update Button, which is supoused to Update that record in the SQL Database. However, for some reason it does not work. I get no error and every thing seems to work fine, but the data is not updated. When running the same UPDATE statment in the SQL Query Analyzer everything works just fine. Here is the code for the button click (For test purpose I've set a spesific record to update the Task cell to "Test" and I've adde a DataGrid to be able to see if something is happening):
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
Dim objConnection As SqlConnection
Dim objDataAdapter As SqlDataAdapter
Dim objDataSet As DataSet
Dim objDataView As DataView
Dim strConnect As String
Dim strSQL As String
Dim strUpdate As String
strConnect = "Persist Security Info=False;Integrated Security=SSPI;server=SRV01;database=DB1"
strSQL = "SELECT * FROM Users WHERE UserID ='" & Request.QueryString("UserID") & "'"
strUpdate = "UPDATE Users SET Task = 'Test' WHERE UserID = 36"     '" & Request.QueryString("UserID") & "'"
objConnection = New SqlConnection(strConnect)
objDataAdapter = New SqlDataAdapter(strSQL, objConnection)
objDataAdapter.UpdateCommand = New SqlCommand(strUpdate)
objDataSet = New DataSet
objDataAdapter.Fill(objDataSet, "User")
objDataView = New DataView(objDataSet.Tables("User"))
dgrTest.DataSource = objDataView
dgrTest.DataBind()
objDataAdapter.ContinueUpdateOnError = True
Try
objDataAdapter.Update(objDataSet, "User")
lblTest.Text = objDataAdapter.UpdateCommand.CommandText
Catch ex As Exception
lblTest.Text = "Error"
End Try
End Sub
 
Thank you for your much needed help in advance.
 

View 3 Replies View Related

Web Form To Update SQL Server 2005 DB

Jul 26, 2007

Bear with me plase as I am nto very familiar with the coding world. The project I am working on is giving me troubles. I am trying to set up a form that can be used on line for our sales staff. It is a call activity form that I was hoping to submit to the DB I Have created in SQL. I would like the sales staff to fill out this form and then have their information transferred to the DB so that I can generate reports from that data. The trouble I am having is getting the intial connection to the DB opened up using the submit button on the form. I go into the code behind the page, and I have entered many scripts with no success. I continue to see that I receive erros when I try to use the opening line:
Dim cn As New ADODB.Connection

If anyone out there has some sample scripting that would help me with this, I would really appreciate it. Thank you.

Marc

View 1 Replies View Related

Query In Dataview/update Form

Dec 23, 2006

Question related to Visual Basic Video Lesson 09 (Databinding.wmv) by Bob Tabor.

Made a table and a UI form according to this lesson (table colums: CustomerID, FirstName, LastName).

Is it possible to use the same or an identical looking query form to find "Bob" by typing Bob in the Fist Name textbox or "Tabor" by typing Tabor in the Last Name textbox as in FileMaker?

Thanks,

View 4 Replies View Related

How Load Tables Form One Database To Another

Aug 1, 2001

Hi,
My problem is I only can put the database table to another database.I use example to ********. For example. My database name is Career. The user has a database name called Online. The Online has already some tables in the database they created before. I just need load my database career tables to the Online database. My database career has seven tables. These tables has a reltionship for each other. I just need to load these table to the Online database, But don't build relation to the tables that already exist in the Online database.
Besides, I want to know how load the stored procedure from my database to another database.

View 1 Replies View Related

On Formview Clicking Update Causes Form Data To Disappear?!?

Mar 24, 2008

Follow-up to:
http://forums.asp.net/t/1237676.aspx
The update command seems to be deleting my data.  If I set the Parameter "DefaultValue" to "NULL" then it updates that field to the literal string: NULL
WTH
Nick
<UpdateParameters>
<asp:Parameter Name="DevelopmentArea" Type="String"/>
<asp:Parameter Name="DevelopmentGoals" Type="String" />
<asp:Parameter Name="DevelopmentPlans" Type="String" />
<asp:Parameter Name="CurrentStatus" Type="String" />
<asp:Parameter Name="FutureState" Type="String" />
<asp:Parameter Name="DetermineFactor" Type="String"/>
<asp:Parameter Name="MentorRequested" Type="Boolean" DefaultValue="False"/>
<asp:Parameter Name="MentorList" Type="String"/>
<asp:Parameter Name="CheckPointDate" Type="DateTime" />
<asp:Parameter Name="DateUpdated" Type="DateTime" />
<asp:Parameter Name="PlanPKID" Type="Int32" />
</UpdateParameters>

View 6 Replies View Related

SQL 2012 :: How To Provide Data In Denormalized Form From Normalized Tables

Apr 14, 2015

I have a requirement to provide data in a denormalized form from normalized tables. Working in SSIS.

I have two tables: EmployeeCountry and Country.

EmployeeCountry
EmployeeId (PK)(FK)
CountryId(PK)(FK)

Country
CountryId (PK)
CountryName

There will only be a max of 3 Country entries for each Employee. So I want to select the EmployeeId and get the three CountryIds so it would look like this:

Employee
EmployeeId
CountryId1
CountryId2
CountryId3

View 9 Replies View Related

Form Field Returns Name With Double Quotes Instead Of Single Quote During Update Process.

Oct 3, 2007

I've a weird problem in my application. In of the pages, while trying to update the text box "Name", when I enter Linda's test, it gets saved as Linda''s test. I'm not sure if this is a problem due to SQL server. When I look at the stored procedure, I don't anything different. Also, when I update the table directly in SQL Server, the result is displayed in single quote. But if I update the field thro' the application, the returned name is with double quotes instead of single quote.  Has any of you faced problems like this? What am I missing? What do I need to do to get the name saved the way I entered (with single quotes) instead of double quotes?

View 1 Replies View Related

Form Criteria Based On An Entered Date And Date Today

Mar 16, 2007

Hi

I am very new to SQL so please excuse me if my question seems too easy to answer.

Basically I need to populate a form based with records based on the criteria that the next mot date and todays are +/- 10 days.

i.e if todays date is 13/05/07 and the next mot date is 3/05/07 or later OR 23/05/07 or less then various fields will be shown in the form.

Can you please help.

Thanks
Paul

View 2 Replies View Related

Update One Table Form Another Table From Different Database And Server

Sep 1, 2015

I need to update the AcquiredFrom table from source_office table. both the tables are from different database and server. we can match them on Code and source code. Initially if we can find out the discrepancies and then how can we fix them. Also there might be some dealerships that would have to be added to acquiredfrom table from the source_office table if they are not there already.

Table 1 (AcquiredFrom) database (Service) Server(FS3)
Select Code, Name, ContactName, AddLine1, AddLine2, city, state, zip, PhoneNumber
FROM [dbo].[AcquiredFrom]
Order by Code
Table 2 (source_office) database (DCP_PROD) Server (DPROSQL)
Select source_code, name, addr1, addr2, city, state_id, zip, phone FROM [dbo].[source_office]
order by source_code

View 9 Replies View Related

Global Temp Tables Getting Dropped Form Time To Time

Apr 10, 2007

Hi all,

I have created several global temp tables to cache some intermediate results ...
However, it seems that after a while those tables will be dropped by SQL Server 2005 automatically (I have not restarted the server and no drop table statement ever executed against those tables). Is this a feature by design? How to make those global temp tables persistence to next service restart?

Thanks,
Ning

View 5 Replies View Related

Getting Out Of Form

Jul 11, 2007

I am trying to add records to SQL database, thru <form> </form> on click of button, The system is working fine, Databse table is getting updated correctly.
But screen displays the same form again while i want it to open another asp.net page i.e. buy.aspx and also generate an e-mail automatically.
I m stuck. Please help.
 pcg
 
Relevent code of mine is as below.
<script runat="server">
    void addtosalelist(Object sender, EventArgs e)    { .... .... dbConnection.Open(); .... ....        dbConnection.Close();     }
 
<form action="buy.aspx" method="post" runat="server">.........<asp:Button id="button1" onclick="addtosalelist" runat="server" Text="Submit"></asp:Button>                                    </form>

View 5 Replies View Related

Help Me Form This SQL?

Mar 2, 2006

Hi all, this'll be my first post here, hopefully I'll get this right and someone can help.

I'm trying to generate a subquery that will take a set of one-column rows and concatenate them into a single cell.

I've adapted from this article (http://www.sqlteam.com/item.asp?ItemID=2368) the following code:
DECLARE @topicList varchar(200)

SELECT @topicList = COALESCE(@topicList + ', ', '') + MAB_topics.topic_name
FROM MAB_topics

SELECT @topicList
that produces a list of all the topic_names in the database seperated by commas. That's fine.

I couldn't follow all the code in this thread (http://www.sqlteam.com/Forums/topic.asp?TOPIC_ID=18363) but I was able to extract and modify this code:

DECLARE @topicList varchar(200)

SELECT MAB_topics.topic_name
INTO #tmp
FROM MAB_topics, MAB_articleIndex
WHERE MAB_articleIndex.article_ID = 76 AND
MAB_topics.topic_ID = MAB_articleIndex.topic_ID

SELECT * FROM #tmp

drop table #tmp
which returns the two topic_names that I'd expect. (Note: this is my very first day declaring variables and using temp tables.) So I keep thinking that the following code would combine the two above working functions. But, when I run it in Query Analyzer, it just returns "(2 row(s) affected)" instead of a recordset.

DECLARE @topicList varchar(200)

SELECT MAB_topics.topic_name
INTO #tmp
FROM MAB_topics, MAB_articleIndex
WHERE MAB_articleIndex.article_ID = 76 AND
MAB_topics.topic_ID = MAB_articleIndex.topic_ID

SELECT @topicList = COALESCE(@topicList + ', ', '') + #tmp.topic_name
FROM #tmp

drop table #tmp
What am I doing wrong? I'm sure it's something simple but I've been reading and trying and reading and trying for a few hours and haven't gotten it yet. The ideal response would figure out what I'm trying to do as well as what my mistake is and explain how I'm misthinking. A close second would be just fixing my code. :)

Thanks in advance,

Chris

View 6 Replies View Related

How To Add Data To SQL Via Web Form?

Feb 19, 2008

HiI am using Visual Web Developer 2005 Express and SQL Server Express 2005.From Northwind I can display data to Gridview.Could someone point me in the right direction on two points.How do I start a new database (.mdf) - I cannot find this option.I can change Northwind around - but I want to start my own database.
Once I have that sorted - how can I "insert" data into database using a dropdown box?A "dropdown" box such as you would find online.
Thanks in advance.Stephen

View 2 Replies View Related

Web Form Button ?

Sep 24, 2004

I need to make a query to a SQLserver db passing values from a dropdownlist and two text boxes as my criteria. Now if nothing is selected and the button is pressed, I would like to return everything that is part of my Select statement. I am having trouble making my sql statement work.

Im sending you my code as an attachment. I've put * around the area i really need help with.

Even if you could just point me in the right direction as to where to look for a good web forms book using VB.NET and ASP.NET I would really appreciate it.

Thanks,

Jose
AIM- RangerBud249
Yahoo- RangerBud249


Imports System.Data.OLEDB
Imports System.Data
Imports System.Data.SqlClient
Public Class Test
Inherits System.Web.UI.Page
Public dbConn As SqlConnection
Public da As SqlDataAdapter
Protected WithEvents txtStart As System.Web.UI.WebControls.TextBox
Protected WithEvents txtEnd As System.Web.UI.WebControls.TextBox
Protected WithEvents Calendar1 As System.Web.UI.WebControls.Calendar
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents img_cal1 As System.Web.UI.WebControls.ImageButton
Protected WithEvents img_cal2 As System.Web.UI.WebControls.ImageButton
Public ds As DataSet

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'the TailNumber is the first thing that will load
If Not Page.IsPostBack Then
lstAircraft.DataSource = GetAircraft() 'this function will load the Tail Numbers
lstAircraft.DataValueField = "TailNumber"
lstAircraft.DataTextField = "TailNumber"
lstAircraft.DataBind()
End If
End Sub

Function GetAircraft() As System.Data.DataSet
'this function will load the Tail Numbers
Dim connectionString As String = "connection info"
Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)

Dim queryString As String = "SELECT [Aircraft].[TailNumber] FROM [Aircraft]"
Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.SqlClient.SqlDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)

Return dataSet
End Function

******************************************************************************************************************
this is the area I really need help with

Sub btm_Submit_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim connectionString As String = "connection info"
Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)
dbConnection.Open()
dbConnection.Close()
Dim selection As String
Dim startTime As String
Dim landingTime As String
Dim flights As String

Dim selString As String = "SSELECT AircraftID, fromLocation, startTime, toLocation, landingTime, ID, Filename, VSU, local_1 FROM Flights, tbl_FileNames, tbl_VSU"

Dim commandString As String = "SELECT [Flights].AircraftID, [Flights].fromLocation, [Flights].startTime, [Flights].toLocation, [Flights].landingTime, [tbl_FileNames].ID, [tbl_FileNames].Filename, [tbl_FileNames].VSU, [tbl_FileNames].local_1 FROM Flights, tbl_FileNames, tbl_VSU"

selection = "where " & Me.lstAircraft.SelectedValue.ToString & " " & startTime = Me.txtStart.Text & " " & Me.txtEnd.Text = landingTime & " " & [Flights].[ID] = [tbl_VSU].[flight_id]) AND [tbl_VSU].[filename_id] = [tbl_FileNames].[ID]"
If Me.txtStart.Text <> "" Then
selString = selString & selection
End If
Session("SelStr") = selString

Dim dbCommand As New OleDbCommand(commandString, dbConnection)

DataGrid1.DataSource = GetFlights(lstAircraft.SelectedValue)
DataGrid1.DataBind()
End Sub
*********************************************************************************************************************

Function GetFlights(ByVal ID As Integer) As System.Data.DataSet
Dim connectionString As String = "connection info"
Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)

Dim queryString As String = "SELECT [Flights].[toLocation], [Flights].[startTime], [tbl_FileNames].[ID], [Flig" & _
"hts].[fromLocation], [tbl_FileNames].[filename], [tbl_FileNames].[Local_1], [Fli" & _
"ghts].[AircraftID], [Flights].[landingTime], [tbl_FileNames].[VSU] FROM [Flights" & _
"], [tbl_FileNames], [tbl_VSU] WHERE (([Flights].[ID] = [tbl_VSU].[flight_id]) AN" & _
"D ([tbl_VSU].[filename_id] = [tbl_FileNames].[ID]))"
Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.SqlClient.SqlDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)

Return dataSet
End Function

Private Sub img_cal1_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles img_cal1.Click
'this will make the calendar for start visible when clicked and not visible if clicked again
Session("Cal1") = True
Session("Cal2") = False
Me.Calendar1.Visible = True
End Sub


Private Sub img_cal2_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles img_cal2.Click
'this will make the calendar for end visible when clicked and not visible if clicked again
Session("Cal2") = True
Session("Cal1") = False
Me.Calendar1.Visible = True

End Sub

Private Sub Calendar1_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Calendar1.SelectionChanged
'this will put the date selected in my text box as a short date
If Session("Cal1") = True Then
txtStart.Text = Calendar1.SelectedDate.ToShortDateString
Session("Cal1") = False
ElseIf Session("Cal2") = True Then
txtEnd.Text = Calendar1.SelectedDate.ToShortDateString
Session("Cal2") = False
End If
Me.Calendar1.Visible = False

End Sub


End Class

View 1 Replies View Related

How To Add SQL Clock In VB Form

Jun 25, 2005

HI I just signed up this forum,I wanted some help.How can i add sql clock on VB Form.
Arshad

View 2 Replies View Related

Form Problems

Jun 10, 2004

Can anyone help me with this problem? I have a form with three drop down lists. From these lists, the user selects an accountID, the territory that ID is from, and the territory that ID is transfering to. Upon submission, that account number is inserted into the table, along with the TerritoryID, RegionID, DivisionID, and EmpID associated with both of the territories selected. However, upon running this, the accountID and ToTerritory info are inserted once, but the FromTerritory data is inserted tens of thousands of times. Although they are not entered into the same record, which i eventually want to happen, i do want to figure out why so many duplicate entries for the FromTerritory are entered. Here is my code and the stored procedure to enter the FromTerritory. I would appreciate any help.
-------------------------

Sub InsertData()



Dim sql as string

dim sql1 = "insertaccounttransfermike 'AccountID''" & AccNumber.SelectedItem.Value & "'"
dim sql2 = "insertaccounttransfermikefrom 'FromTerritory''" & FromName.SelectedItem.Value & "'"
dim sql3 = "insertaccounttransfermiketo 'ToTerritory''" & ToName.SelectedItem.Value & "'"

' Create Connection Object, Command Object, Connect to the database
Dim conn as New SQLConnection(connstr)

Dim cmd1 as New SQLCommand(sql1,conn)
Dim cmd2 as New SQLCommand(sql2,conn)
Dim cmd3 as New SQLCommand(sql3,conn)

conn.open()
cmd1.ExecuteNonQuery()
cmd2.ExecuteNonQuery()
cmd3.ExecuteNonQuery()
conn.Close()

' go to the datagrid query page
Response.redirect(return_page)

end sub

--------------------------
CREATE PROCEDURE InsertAccountTransferMikefrom

@FromTerritory nvarchar(50)

AS

Insert INTO AccountTransfersTestMike

(FromTerritoryID, FromRegionID, FromDivisionID, FromEmpID)

SELECT Territories.TerritoryID, Regions.RegionID, Divisions.DivisionID, Employees.EmployeeID
FROM EndoscopySqlUser.Territories INNER JOIN
EndoscopySqlUser.Regions ON EndoscopySqlUser.Territories.RegionName = EndoscopySqlUser.Regions.Region INNER JOIN
EndoscopySqlUser.Employees ON EndoscopySqlUser.Territories.TerritoryID = EndoscopySqlUser.Employees.TerritoryID INNER JOIN
EndoscopySqlUser.Divisions ON EndoscopySqlUser.Regions.Division = EndoscopySqlUser.Divisions.DivisionID, accounts
WHERE ( (EndoscopySqlUser.Employees.DateLeft IS NULL) AND (EndoscopySqlUser.Territories.TerritoryName=@FromT erritory))
GO

View 1 Replies View Related

How To Form Query?

Jul 24, 2004

i am using this statement

select dateadd(dd,1,20010331)


and it's throwing an error

Arithmetic overflow error converting expression to data type datetime.

what's wrong?

View 2 Replies View Related

Form With 20,500 Fields

Jan 27, 2004

I'm running SQL Server 2000. I have an interesting form I am creating for a client which has on it literally 20,500 fields that need to be stored in the system which I then have to create reports off of for statistics and trends.

I'm not sure how I should go about storing that large amount of information in SQL Server with the limitations of the size of a table. Would it be best to create 20 some tables to store it, or is there a better fashion to store it. 90% of the fields are numbers ranging from 0 to 100.

Thanks for any suggestions you can come up with!

View 14 Replies View Related

How To Form The Query

Apr 5, 2008

I have two tables. The table is below.

Table name 1 : Income
Income RentMonth
1500 Jan
1500 Feb
1500 Apr

Table name 2 : Expense
Expense ExpMonth
200 Jan
300 Mar
400 Apr

The result table becomes (Profit=Income-Expense)
Profit Month
1300 Jan
1500 Feb
-300 Mar
1100 Apr

But I form the query by join the both Income and Expense tables to subtract the Income and Expense month wise.

But one moth is in one table the same month is not in another table.

For Example Feb month is in Income table, but not in Expense table.And Mar month is in Expense table and not in Income table. So how will I form the query to achieve my result table as i indicated above. Kindly help me.

Kamal.

View 2 Replies View Related

Please Help! ASP Form To SQL Database

Apr 25, 2008

I'm using SQL server on godaddy.com, and for the life of me, tried all freakin day yesterday to get a form to send data to my table, and can't get it to work for the life of me

I think the asp form sends the information to the asp page that is to add the information to the tables correctly, but am not entirely sure, so here is the code for the form:

<html>
<head>
<title>Form Entry</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body><form method="post" action="add.asp">
<table>
<tr>
<td>CustomerID:</td>
<td><input name="CustID"></td>
</tr><tr>
<td>Company Name:</td>
<td><input name="Company"></td>
</tr><tr>
<td>Contact Name:</td>
<td><input name="Contact"></td>
</tr><tr>
<td>Address1:</td>
<td><input name="Address1"></td>
</tr><tr>
<td>Address2:</td>
<td><input name="Address2"></td>
</tr><tr>
<td>Address3:</td>
<td><input name="Address3"></td>
</tr><tr>
<td>City:</td>
<td><input name="City"></td>
</tr><tr>
<td>State:</td>
<td><input name="State"></td>
</tr><tr>
<td>Zip:</td>
<td><input name="Zip"></td>
</tr>
<td>Email:</td>
<td><input name="Email"></td>
</tr><tr>
<td>Phone:</td>
<td><input name="Phone"></td>
</tr>
</table>
<br /><br />
<input type="submit" value="Add New">
<input type="reset" value="Cancel">
</form>
</body>
</html>


Now for the page that is giving me the problem (I think). I'm pretty sure I'm fudging up the connectivity somewhere because all I get is an http 500 error every time I try to upload the information.

Why won't it bloody connect?!?!

Also, is the DIM function on this page used to hide important information? If you guys can help me fix this, I'd be incredibly, incredibly greatful, I'm frustrated out of my mind!

<%@LANGUAGE="JAVASCRIPT" CODEPAGE="CP_ACP"%>
<html>
<head>
<title>piece of shit page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<%
Dim oConn, oRs
Dim qry, connectstr
Dim db_name, db_username, db_userpassword
Dim db_server

db_server = "whsql-v22.prod.mesa1.secureserver.net"
db_name = "Fulfillment"
db_username = "Fulfillment"
db_userpassword = "your_password"
tablename = "KSEP_Customers"

connectstr = "Driver={SQL Server};SERVER=" & db_server & ";DATABASE=" & db_name & ";UID=" & db_username & ";PWD=" & db_userpassword

set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"sql="INSERT INTO customers (CustID,companyname,"
sql=sql & "contactname,address,city,postalcode,country)"
sql=sql & " VALUES "
sql=sql & "('" & Request.Form("CustID") & "',"
sql=sql & "'" & Request.Form("Company") & "',"
sql=sql & "'" & Request.Form("Contact") & "',"
sql=sql & "'" & Request.Form("Address1") & "',"
sql=sql & "'" & Request.Form("Address2") & "',"
sql=sql & "'" & Request.Form("Address3") & "',"
sql=sql & "'" & Request.Form("City") & "',"
sql=sql & "'" & Request.Form("State") & "',"
sql=sql & "'" & Request.Form("Zip") & "',"
sql=sql & "'" & Request.Form("Email") & "',"
sql=sql & "'" & Request.Form("Phone") & "')"on error resume next
conn.Execute sql,recaffected
if err<>0 then
Response.Write("No update permissions!")
else
Response.Write("<h3>" & recaffected & " record added</h3>")
end if
conn.close
%>

</body>
</html>

View 4 Replies View Related

Login Form Gets Ignored

Jun 8, 2006

I have a Visual Basic application that connects to a SQL server database. In my application, I have a login screen that is supposed to pause the application (it's coded as modal) and ask the user for a login and password. I have my connection string and user set up to use Windows NT authentication.

However, what is happening with my application is that as soon as I start the program, it never stops at the login screen, but instead goes right into the application.

Is this "normal" when using Windows NT authentication? What causes this behavior? How can I make my program stop at the login screen, and more interestingly, would I want to stop at a login screen?

Thanks in advance to all who reply. This is driving my crazy!

This forum is best viewed with a computer. Questions asked freely. Confusion happily shared.

View 2 Replies View Related

How Output On A Form?

Oct 10, 2006

Vuyo writes "how do you output values from the database to a form(.NET Platform)?"

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved