How Can I Retrieve The Data Back Into The Webform From The Database?

Feb 27, 2008

Hi,
I m using vwd2005 and sql express,c#.
I have a question here.
In my database i have a table named Table1(id,name,age,country,email,phone) 
The values for these fields are inserted from the webform.
Id is auto generated.
name and age is passed from the textbox within the webform.
country is passed from dropdownlist within the webform.
email and phone is passed from listbox(multiple email and phone) within the webform.
Now my problem is i want to retrieve all these row values back into the textboxes,dropdownlist and listbox at the same time
on the click of the retrieve button within the web form . 
Further more i want to make few changes on it and update the database on the click of another button update within the form.
I hope u are getting it.
How would the query would be in this case.?
can u demonstrate the concept in one simple running example along with code?
thanks.
jack. 

View 3 Replies


ADVERTISEMENT

**I M Not Able To RETRIEVE Data Back Into Webform From The Database?

Mar 25, 2008

Hello Everyone,I 've trying to retreive data back into webform from the database from past couple of weeks.But i m not able to retrieve it completely.Here is my scenario.I've tried to explain in detail but in simple language.I hope u will get my point.Ok here it is.plz run my code:-i have three tables in sql.they are:-grup(id,grp)      (1,abc)      (2,xyz)      organization(id,oid,gid,organisation,orgphone)                  (1,1,1,ibm,1234567)                  (2,1,2,microsoft,6543210)                  (3,2,1,oracle,7654323)                  (4,2,2,apple,9876543)  userform(id,title,name,address,email,organizationid)              (1,mr,jack,usa,jack@jack.com,1) userform.aspx page<%@ Page Language="C#" AutoEventWireup="true" CodeFile="userform.aspx.cs" Inherits="userform" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server">    <title>Untitled Page</title></head><body>    <form id="form1" runat="server">    <div>        <div style="text-align: center">            <table>                <tr>                    <td style="width: 100px">                        Title</td>                    <td style="width: 100px">                        <asp:DropDownList ID="DropDownList1" runat="server">                            <asp:ListItem>mr</asp:ListItem>                            <asp:ListItem>miss</asp:ListItem>                            <asp:ListItem>ms</asp:ListItem>                        </asp:DropDownList></td>                </tr>                <tr>                    <td style="width: 100px">                        Name</td>                    <td style="width: 100px">                        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td>                </tr>                <tr>                    <td style="width: 100px">                        Add</td>                    <td style="width: 100px">                        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox></td>                </tr>                <tr>                    <td style="width: 100px; height: 26px;">                        Email</td>                    <td style="width: 100px; height: 26px;">                        <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox></td>                </tr>            </table>        </div>        </div>        <div style="text-align: center">            <div>                <div>                    <asp:ScriptManager ID="ScripManager1" runat="server">                    </asp:ScriptManager>                    <div>                        <table>                            <tr>                                <td style="width: 100px">                        Group</td>                                <td style="width: 100px">                                   
<asp:DropDownList ID="ddl1" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="ddl1_SelectedIndexChanged">                                    </asp:DropDownList></td>                            </tr>                        </table>                        &nbsp;</div>                    <div>                        <asp:UpdatePanel ID="UpdatePanel1" runat="server">                            <ContentTemplate>                                <table>                                    <tr>                                        <td>                        Organisation&nbsp;</td>                                        <td>                                           
<asp:DropDownList ID="ddl2" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="ddl2_SelectedIndexChanged">                                            </asp:DropDownList>&nbsp;                                        </td>                                    </tr>                                    <tr>                                        <td>                        org-phone&nbsp;</td>                                        <td>                        <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>&nbsp;</td>                                    </tr>                                    <tr>                                        <td>                                        </td>                                        <td>                                           
<asp:TextBox ID="TextBox5" runat="server"
Width="45px"></asp:TextBox></td>                                    </tr>                                </table>                            </ContentTemplate>                            <Triggers>                                <asp:AsyncPostBackTrigger ControlID="ddl1" EventName="SelectedIndexChanged" />                            </Triggers>                        </asp:UpdatePanel>                        <br />                        <table>                            <tr>                                <td style="width: 100px">                        <asp:Button ID="Button1" runat="server" Text="save" OnClick="Button1_Click" />                                </td>                                <td style="width: 100px">                                    <asp:Button ID="Button3" runat="server" Text="update" /></td>                                <td style="width: 100px">                        <asp:Button ID="Button2" runat="server" Text="cancel" /></td>                            </tr>                        </table>                    </div>                </div>            </div>        </div>    </form></body></html>userform.cs page public partial class userform : System.Web.UI.Page{    protected void Page_Load(object sender, EventArgs e)    {        if (!Page.IsPostBack)        {            AssignDDLDataSource();            ddl1_SelectedIndexChanged(null, null);        }    }        private void AssignDDLDataSource()    {                // SqlConnection             string sqlQry = "SELECT GRP DISPMEM, ID VALMEM FROM GRUP";        SqlCommand cmd = new SqlCommand(sqlQry, con);        ddl1.DataSource = cmd.ExecuteReader();        ddl1.DataTextField = "DISPMEM";        ddl1.DataValueField = "VALMEM";        ddl1.DataBind();    }    protected void ddl1_SelectedIndexChanged(object sender, EventArgs e)    {        AssignSubjectDDL(ddl1.SelectedValue);    }    private void AssignSubjectDDL(string val)    {       // SqlConnection        string sqlQry = "SELECT ORGANISATION DISPMEM, GID VALMEM FROM ORGANIZATION where OID = '" + val + "'";        SqlCommand cmd1 = new SqlCommand(sqlQry, con);        ddl2.DataSource = cmd1.ExecuteReader();        ddl2.DataTextField = "DISPMEM";        ddl2.DataValueField = "VALMEM";        ddl2.DataBind();        ddl2_SelectedIndexChanged(null, null);    }    protected void ddl2_SelectedIndexChanged(object sender, EventArgs e)    {        AssignTextBoxValues(ddl1.SelectedValue, ddl2.SelectedValue);    }    private void AssignTextBoxValues(string teamval, string memval)    {         // SqlConnection       
string sqlQry = "Select ID,ORGANISATION,ORGPHONE from ORGANIZATION
where OID = '" + teamval + "' AND GID = '" + memval + "'";        SqlCommand cmd = new SqlCommand(sqlQry, con);        SqlDataReader rdr = cmd.ExecuteReader();        while (rdr.Read())        {            TextBox5.Text = rdr["ID"].ToString().Trim();            TextBox4.Text = rdr["ORGPHONE"].ToString().Trim();        }    }    protected void Button1_Click(object sender, EventArgs e)    {       // SqlConnection       
string sqlQry = "INSERT into USERFORM (title, name, address, email,
organizationid) VALUES(@title,@name,@address,@email,@organizationid)";        SqlCommand cmd = new SqlCommand(sqlQry, con);        cmd.CommandType = CommandType.Text;        cmd.Parameters.AddWithValue("title", DropDownList1.SelectedValue.Trim());        cmd.Parameters.AddWithValue("name", TextBox1.Text);        cmd.Parameters.AddWithValue("address", TextBox2.Text);        cmd.Parameters.AddWithValue("email", TextBox3.Text);        cmd.Parameters.AddWithValue("organizationid", TextBox5.Text);        cmd.ExecuteNonQuery();        Response.Redirect("detailsview.aspx");    }} detailsview.aspx <%@ Page Language="C#" AutoEventWireup="true" CodeFile="detailsview.aspx.cs" Inherits="detailsview" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server">    <title>Untitled Page</title></head><body>    <form id="form1" runat="server">    <div>        <asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" EnablePagingCallbacks="True"            Height="50px" HorizontalAlign="Center" Width="125px">        </asp:DetailsView>        </div>    </form></body></html> detailsview.cspublic partial class detailsview : System.Web.UI.Page{    protected void Page_Load(object sender, EventArgs e)    {        //SqlConnection        
string str = "select title,name,address,email,grp,organisation,orgphone
from userform as a inner join organization as b on
a.organizationid=b.id inner join grup as c on b.oid=c.id";        SqlDataAdapter oda = new SqlDataAdapter(str, conn);        conn.Open();        DataSet ods = new DataSet();        oda.Fill(ods, "info");        DetailsView1.DataSource = ods.Tables["info"].DefaultView;        DetailsView1.DataBind();              }}My problem :-Now when user fills up the userform and clicks the save button the details are shown in the details view.Now i want to add a Edit hyperlink next to the records in the detailsview so that when i click on it i would be redirected to userform.aspx form with all the textboxes,dropdownlist etc be populated from the related data from the database.(here table userform).Now i want to edit these data in the userform.aspx page and finally when i click the update button at end i want all the data be updated in the database aswell as in details view too.at the same time i want this form to redirect to detailsview.aspx .i hope ur getting it?i m able to do partial part only.Not completely. So can u now  help me modify the code accordingly?Thanks in advance.Jack.  

View 4 Replies View Related

Webform Time Out Trying To Retrieve From Different Tables

Jun 9, 2006

I'm having a problem retrieving information from two different tables. Everytime i run a query which i type a source id into a textbox my page keeps timing out. What could be the problem? The tables i'm pulling from is profiles and phone. Here is the code. If someone could tell me what's going on id apperciate it. Thanks!
 
Dim queryString As String = "SELECT [profiles].[date_added], [profiles].[source_id], [RP_profiles].[fnam"& _"e], [profiles].[lname], [profiles].[title], [phone].[number], [RP_phone"& _"].[source_id] FROM [profiles], [phone] WHERE ([profiles].[source_id] = "& _"@source_id)"
 
 

View 3 Replies View Related

Want To Compare Webform Input To Database

Apr 9, 2008

 Hello, I am writing a website (in vb) to allow for room use reservations and I am looking for a way to compare the selected start and end times which are date-time format to records already in the database for that  day/time  and specific room.  If the selected time does not fall within an already reserved time frame I then want to insert it into the table.  I have already written a procedure to do the inserting and that works fine.  I just want to validate it before calling the insert.  Any ideas?  The fields to be validated on the form are textboxes containing date time which populate as read only after the time selection is chosen from dropdown. Thanks in advance It's greatly appreciated.

View 7 Replies View Related

What Am I Doing Wrong? I Just Want To Modify My Database From A Webform.

Feb 20, 2006

Windows XP
SQL Expresss 2005
SQL Express 2005 Manager
 
I simply want to edit and data I have in a database that I made with Express Manager. This worked before .Net 2.0. Now, I have the table displayed as a datagrid with an "edit" pushbutton associated with each row in the database table. When I click on the "edit" pushbutton to edit a specific row in the database table, instead of posting me to a page where the chosen row is editable, I am posted back to the same page without the chosen row availible to be edited.
What am I doing wrong? How can I fix this? I am totally new to this so any help would be appreciated.
Cheers!
<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="iso-8859-1" EnableEventValidation="false" %><%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicKeyToken=836f606ede05d46a,culture=neutral" %><MM:DataSet id="dsParts"runat="Server"IsStoredProcedure="false"ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_STRING_PartsAreUs"] %>'DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_DATABASETYPE_PartsAreUs"] %>'CommandText='<%# "SELECT * FROM dbo.Parts" %>'Debug="true">  <EditOps>    <EditOpsTable Name="dbo.Parts" />      <Parameter Name="Name" Type="VarChar" />      <Parameter Name="Description" Type="NVarChar" />      <Parameter Name="Price" Type="Money" />      <Parameter Name="PartID" Type="Int" IsPrimary="true" />    </EditOps></MM:DataSet><MM:PageBind runat="server" PostBackBind="true" /><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>Untitled Document</title></head><body><form runat="server">  <asp:DataGrid id="dgParts"   runat="server"   AllowSorting="False"   AutoGenerateColumns="false"   CellPadding="3"   CellSpacing="0"   ShowFooter="false"   ShowHeader="true"   DataSource="<%# dsParts.DefaultView %>"   PagerStyle-Mode="NextPrev"         DataKeyField="PartID"  onCancelCommand="dsParts.OnDataGridCancel"   onEditCommand="dsParts.OnDataGridEdit"   onUpdateCommand="dsParts.OnDataGridUpdate"   onItemDataBound="dsParts.OnDataGridItemDataBound" >    <HeaderStyle HorizontalAlign="center" BackColor="#E8EBFD" ForeColor="#3D3DB6" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Bold="true" Font-Size="smaller" />    <ItemStyle BackColor="#F2F2F2" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Size="smaller" />    <AlternatingItemStyle BackColor="#E5E5E5" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Size="smaller" />    <FooterStyle HorizontalAlign="center" BackColor="#E8EBFD" ForeColor="#3D3DB6" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Bold="true" Font-Size="smaller" />    <PagerStyle BackColor="white" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Size="smaller" />    <Columns>    <asp:EditCommandColumn         ButtonType="PushButton"         CancelText="Cancel"         EditText="Edit"         HeaderText="Edit"         UpdateText="Update"         Visible="True"/>    <asp:BoundColumn DataField="PartID"         HeaderText="PartID"         ReadOnly="true"         Visible="True"/>    <asp:BoundColumn DataField="Name"         HeaderText="Name"         ReadOnly="false"         Visible="True"/>    <asp:BoundColumn DataField="Description"         HeaderText="Description"         ReadOnly="false"         Visible="True"/>    <asp:BoundColumn DataField="Price"         HeaderText="Price"         ReadOnly="false"         Visible="True"/>    </Columns>  </asp:DataGrid></form></body></html>
 

View 3 Replies View Related

Problem Inserting Data Into SQL Server 2005 DB From WebForm Controls

Mar 30, 2007

Hello all,
I am having problems running a stored proc from an aspx.cs file. Basically I want to extract data from webForm controls and create a new record in a DB table. I have watched the "Getting Started" videos on thi site, and the only difference between my code and the code of the demonstrator is the connection string.   My conn string:- dataSrc.ConnectionString = ConfigurationManager.ConnectionStrings["ProjectTblConnString"].ConnectionString;Demonstrator conn string:- dataSrc.ConnectionString = ConfigurationManager.ConnectionStrings("ProjectTblConnString");When I debug with the string as shown by the demonstrator the error list reports that ConnectionStrings is a property and I am trying to use it as a mothod, which is fair enough, but I am just confused as how it worked for the demonstrator and not myself. When I debug with the code I used above I get no error, but nothing is inserted in the DB.Also, it looks as if the only class in my aspx.cs file that is actually being executed is PageLoad() - the remainder of the code seems to be ignored. Below is the entired aspx.cs file:- 1 using System;
2 using System.Data;
3 using System.Configuration;
4 using System.Collections;
5 using System.Web;
6 using System.Web.Security;
7 using System.Web.UI;
8 using System.Web.UI.WebControls;
9 using System.Web.UI.WebControls.WebParts;
10 using System.Web.UI.HtmlControls;
11
12 public partial class CreateProject : System.Web.UI.Page
13 {
14 protected void Page_Load(object sender, EventArgs e)
15 {
16
17 if (User.Identity.IsAuthenticated == false)
18 {
19 Server.Transfer("Default.aspx");
20 }
21
22 if (chkbox_startDate.Checked == true)
23 {
24 txtbox_startDate.ReadOnly = true;
25 txtbox_startDate.Text = (System.DateTime.Now.ToString());
26 }
27
28 }
29
30 protected void btn_create_Click(object sender, EventArgs e)
31 {
32 //connection string for connecting to SQL Server DB
33 SqlDataSource dataSrc = new SqlDataSource();
34 dataSrc.ConnectionString = ConfigurationManager.ConnectionStrings["ProjectTblConnString"].ConnectionString;
35
36
37 //insert data in table using the CreateNewProject stored proc in the DB
38 dataSrc.InsertCommandType = SqlDataSourceCommandType.StoredProcedure;
39 dataSrc.InsertCommand = "CreateNewProject";
40 dataSrc.InsertParameters.Add("Project_Title", txtbox_title.ToString() );
41 dataSrc.InsertParameters.Add("Description", txtbox_desc.ToString() );
42 dataSrc.InsertParameters.Add("Start_Date", txtbox_startDate.ToString() );
43 dataSrc.InsertParameters.Add("Primary_Dev_Lang", list_devLang.ToString() );
44 dataSrc.InsertParameters.Add("Dev_Environment", list_devEnv.ToString() );
45 dataSrc.InsertParameters.Add("No_Junior_Devs", txtbox_juniorDevs.ToString() );
46 dataSrc.InsertParameters.Add("No_Senior_Devs", txtbox_seniorDevs.ToString() );
47
48 int rowsAffected = 0;
49 try
50 {
51 rowsAffected = dataSrc.Insert();
52 }
53 catch (Exception ex)
54 {
55 Server.Transfer(Error.aspx);
56 }
57 finally
58 {
59 dataSrc = null;
60 }
61
62 if (rowsAffected != 1)
63 {
64 label_confirm.Text = "Error, Contact system admin";
65 }
66 else
67 {
68 label_confirm.Text = "Success";
69 }
70
71 }//end btn_create
72
73 //if cancel is clicked set all values back to default
74 protected void btn_cancel_Click(object sender, EventArgs e)
75 {
76 txtbox_title.Text = "";
77 txtbox_desc.Text = "";
78 txtbox_startDate.Text = "";
79 txtbox_seniorDevs.Text = "";
80 txtbox_juniorDevs.Text = "";
81 list_devEnv.SelectedIndex = 0;
82 list_devLang.SelectedIndex = 0;
83 chkbox_startDate.Checked = true;
84 label_confirm.Text = "";
85 }
86
87 //if checked the current dateTime is inserted into txtbox
88 protected void chkbox_startDate_CheckedChanged(object sender, EventArgs e)
89 {
90 if (chkbox_startDate.Checked == true)
91 {
92 txtbox_startDate.ReadOnly = true;
93 txtbox_startDate.Text = (System.DateTime.Now.ToString());
94 }
95 else
96 {
97 txtbox_startDate.ReadOnly = false;
98 txtbox_startDate.Text = "";
99 }
100 }//end chkox
101
102
103 }//end class
 
Any help anyome can give is greatly appreciated. This is part of my Final Year College Dissertation which is due in 3wks !!!!
Sláinte á chaire,
Seán
 

View 2 Replies View Related

Best Way To Insert Large Amounts Of Data From A Webform To SQL Server 2005

Oct 21, 2007

HiI have a VB.net web page which generates a datatable of values (3 columns and on average about 1000-3000 rows).What is the best way to get this data table into an SQL Server? I can create a table on SQL Server no problem but I've found simply looping through the datatable and doing 1000-3000 insert statements is slow (a few seconds). I'd like to make this as streamlined as possible so was wondering is there is a native way to insert all records in a batch via ADO.net or something.Any ideas?ThanksEd

View 1 Replies View Related

How To Retrieve Data As XML From SQL Database

Feb 28, 2007

Hi,
I have a website which is designed to search for employee information. I have the search system working which does exactly what I want to, but as an added feature I want there to be a button which, when someone clicks on it, it takes whatever the previous search was and generates a set of data in XML format which is based on the results. For example:
User searches for all entries with Forename = John; Results are listed in a gridview as per expected.
User then presses button with XML on it, and page pops up with just the XML output on it, i.e. whatever results are on the gridview but in a nested XML format
<records>    <record>       <Forename>John</Forename>       <Surname>Smith</Surname>       <Email>j.smith@blah.com</Email>       <Ext>1234</Ext>       <DeptList>History</DeptList>    </record></records>
I have created a stored procedure which will take the parameters from the search boxes and return the above information, but I don't know if this is the best way. Here it is for those interested:
CREATE PROCEDURE ps_record_SELECT_NameSurnameEmailExtDeptasXML
@Forename varchar(50),
@Surname varchar(50),
@Email varchar(50),
@Ext varchar(4),
@DeptList varchar(50)
AS
SELECT Forename, Surname, Email, Ext, DeptList
FROM dbo.record
WHERE Forename LIKE COALESCE(@Forename,Forename) AND
Surname LIKE COALESCE(@Surname,Surname) AND
Email LIKE COALESCE(@Email,Email) AND
Ext LIKE COALESCE(@Ext,Ext) AND
DeptList LIKE COALESCE(@DeptList,DeptList)
FOR XML AUTO, ELEMENTS
If someone could be kind enough to help me out with this, I'd be really grateful.
Many thanks,
Tom

View 2 Replies View Related

Retrieve Data From Different Database

Sep 24, 2007

Hi, Im new to SQL 2005.
I want to know that, any way i can use to get data from different database?

View 2 Replies View Related

Getting Data From Dataset Back Into Database

Sep 7, 2006

I'm new at this so I apologize in advance for my ignorance.

I'm creating a website that collects dates in a calendar control (from Peter Blum). When the page containing the control loads it populates the calendar with dates from the database (that have previously been selected by the user). The user then can delete existing dates and/or add new dates.

I create a dataset when the page loads and use it to populate the calendar. When the user finishes adding and deleting dates in the calendar control I delete the original dates from the dataset and then write the new dates to the dataset. I then give execute the data adapter update command to load the contents of the dataset back into the database. This command involves using parameterized queries. For example the Insert command is:

Dim cmdInsert As SqlCommand = New SqlCommand("INSERT INTO Requests VALUES(@fkPlayerIDNumber, @RequestDate, @PostDate, @fkGroupID)", conn)

cmdInsert.Parameters.Add(New SqlParameter("@fkPlayerIDNumber", SqlDbType.Int))

cmdInsert.Parameters.Add(New SqlParameter("@RequestDate", SqlDbType.DateTime))

cmdInsert.Parameters.Add(New SqlParameter("@PostDate", SqlDbType.DateTime))

cmdInsert.Parameters.Add(New SqlParameter("@fkGroupID", SqlDbType.Int))

da.InsertCommand = cmdInsert

The update command is:

da.Update(ds, "Requests")

When I run the program I get the following error:

Parameterized Query '(@fkPlayerIDNumber int,@RequestDate datetime,@PostDate datetime,' expects parameter @fkPlayerIDNumber, which was not supplied.

I've used debug print to establish that the table in the dataset contains what it should.

I would be more than grateful for any suggestions.

View 3 Replies View Related

Dropdownlist Retrieve Data From Sql Database

Feb 13, 2008

i have 2 dropdownlist which is  ddlCategory and ddlItem.i want<<< a)both ddl get data from sql db.b)view the data in gridview.   i need code in vb.net to retrieve and post.tq  

View 1 Replies View Related

How To Correctly Propogate Data Back To The Database

Jul 23, 2005

I have the following code but do not know the best way to return the updatedDataTable back to the database. I believe I can use the Update method of theData Adapter, BUT if true, I also believe I have to 'long-hand' write codefor each individual column data that's being added......this seems a bitdaft considering that the data is already in the disconnected data table.Have I lost the plot?? Based on the code below, what is the correctapproach?Note: sqlcnn is defined at module level.Public Sub AddRequest(ByVal Eng As String, ByVal Bran As String, ByVal ReqAs String) Implements IHelpSC.AddRequestDim dtNew As New DataTable("dtNew")Dim drNew As DataRowsqlda = New SqlDataAdapter("SELECT * FROM ActiveCalls", sqlcnn)sqlda.Fill(dtNew)'Add and populate the new datarow with'data passed into this subroutinedrNew = dtNew.NewRowdrNew("CallTime") = Format(Date.Now, "dd MMM yyyy").ToStringdrNew("Engineer") = EngdrNew("Branch") = BrandrNew("Request") = ReqdtNew.Rows.Add(drNew)End SubHope one of you wizards can help.Rgds.....and Merry Christmas.Phil

View 2 Replies View Related

How To Transfer Back Data To Production Database

Nov 19, 2015

I have question regarding SQL Transactional Replication methodology

1. Let's say successfully created SQL Transactional Replication and running / transferring data from publisher to subscriber

2. Now one day the source production / publisher SQL Server is down and the remaining DR SQL Server is up (subscriber)

3. Next day, we fixed and bring up the production / publisher SQL Transactional Replication server, then how can we sync back all existing data records from subscriber into publisher side ?

View 3 Replies View Related

Mirroring :: Principal Database Get Role Back After Being Back On Line

May 14, 2015

New to Database Mirroring and I have a question about the Principal database server. I have a Database Mirroring setup configured for High-safety with automatic fail over mode using a witness.

When a fail over occurs because of a lost of communication between the principal and mirror, the mirror server takes on the roll of Principal. When communication is returned to the Principal server, at some point does the database that was the previous Principal database automatically go back to being the Principal server?

View 2 Replies View Related

Retrieve Data From Database And Display It In A Label

Jan 21, 2008

Below is code for inserting data into the database that I know works, so I thought if I replace  "Insert" with "Select" I could retrieve a specific row from my database and present it in a label or text box but nothing happened. How can I retrieve a row or rows from a database using vb code and display it in a textbox? I'm using visual web developer 2008 which is similar to 2005.
Thank you.
 
 Dim UserDatasource As New SqlDataSourceUserDatasource.ConnectionString = ConfigurationManager.ConnectionStrings("ASPNETDBConnectionString1").ToString()
 
UserDatasource.InsertCommandType = SqlDataSourceCommandType.Text
UserDatasource.InsertCommand = "insert into table1 (Username, comments, points,totalpoints, ipaddress, datatimestamp) values (@Username, @comments, @points,@totalpoints, @ipaddress, @datatimestamp)"
 
 UserDatasource.InsertParameters.Add("username", Context.User.Identity.Name)
UserDatasource.InsertParameters.Add("comments", txtSearch.Text)UserDatasource.InsertParameters.Add("points", points)
UserDatasource.InsertParameters.Add("ipaddress", Request.UserHostAddress)UserDatasource.InsertParameters.Add("datatimestamp", DateTime.Now())
 Dim rowaffected As Integer = 0
 
Try
rowaffected = UserDatasource.Insert()MsgBox("Thanks for the post", MsgBoxStyle.OkOnly, "Post Executed")
txtSearch.Text = ""Catch ex As Exception
MsgBox("Please sign in or sign up to post comment", MsgBoxStyle.OkOnly, "Login Error")
End Try
 

View 2 Replies View Related

How Do I Restore Sql Server Database Primary Data Back .mdf

Feb 12, 2007

 
Hello guys
My server crashed  but luckily  I was not able to get back my files with help of recovery software.
Now, all I have from the database are just sql server database primary data .mdf and sql server databaseTransaction Log Files .ldf. I need to restore  these data back to sql server.

Please could someone tell me how to restore these two file types back to my sql sever 2007 database?
Thanks
netboy
 
 

View 3 Replies View Related

Insert Information And To Database And Retrieve The ID Created For That Row Of Data In The Table

May 4, 2007

Hi,
 I am working on inserting information into a DB and then retrieving the ID created for that Data to use elsewhere in my code. I have the code below but I do not know how to get toOutput parameter. Can anyone please help?
  
CREATE PROCEDURE dbo.InsertProduction
@DATEOUT datetime(8),
@DATEREQUIRED datetime(8),
@PREPAREDBY varchar,
@COMMENTID INteger,
@TOTALQUANTITY INteger,
@VENDORID INteger,
@WPO varchar,
@TCAPONUMBER INteger,
@APPROVEDBY varchar,
@Identity int OUT
 
AS
INSERT INTO PRODUCTION (DATEOUT,DATEREQUIRED, PREPAREDBY, COMMENTID, TOTALQUANTITY, VENDORID, WPO, TCAPONUMBER, APPROVEDBY) VALUES( @DATEOUT, @DATEREQUIRED, @PREPAREDBY, @COMMENTID, @TOTALQUANTITY, @VENDORID, @WPO, @TCAPONUMBER, @APPROVEDBY)
SET @Identity = SCOPE_IDENTITY()
 
 
'collect all the information from the form and then apply all and then update
'Get a reference to the Production table.
Dim dtProduction As DataTable = DS.Tables("Production")
Dim dtLineItem As DataTable = DS.Tables("LineItems")
' Create the SqlCommand to execute the stored procedure.
Production.InsertCommand = New SqlCommand("dbo.InsertProduction", connection)
Production.InsertCommand.CommandType = CommandType.StoredProcedure
' Add the parameter for the CategoryName. Specifying the
' ParameterDirection for an input parameter is not required.
'Production.InsertCommand.Parameters.Add("@CategoryName", SqlDbType.NVarChar, 15, "CategoryName")
Production.InsertCommand.Parameters.Add("@DATEOUT", SqlDbType.DateTime, 8, "CategoryName")
Production.InsertCommand.Parameters.Add("@DATEREQUIRED", SqlDbType.DateTime, 8, "CategoryName")
Production.InsertCommand.Parameters.Add("@PREPAREDBY", SqlDbType.VarChar, 50, "CategoryName")
Production.InsertCommand.Parameters.Add("@COMMENTID", SqlDbType.Int, 4, "CategoryName")
Production.InsertCommand.Parameters.Add("@TOTALQUANTITY", SqlDbType.Int, 4, "CategoryName")
Production.InsertCommand.Parameters.Add("@VENDORID", SqlDbType.Int, 4, "CategoryName")
Production.InsertCommand.Parameters.Add("@WPO", SqlDbType.VarChar, 50, "CategoryName")
Production.InsertCommand.Parameters.Add("@TCAPONUMBER", SqlDbType.Int, 4, "CategoryName")
Production.InsertCommand.Parameters.Add("@APPROVEDBY", SqlDbType.VarChar, 50, "CategoryName")
' Add the SqlParameter to retrieve the new identity value.
' Specify the ParameterDirection as Output.
Dim parameter As SqlParameter = Production.InsertCommand.Parameters.Add("@Identity", SqlDbType.Int, 0, "ProductionID")
parameter.Direction = ParameterDirection.Output
' Create a new row with the same schema.
Dim dr As DataRow = dtProduction.NewRow()
'you need the ID from this to insert into the Production DB
' Set the value of all the columns.
dr("DateOut") = CDate(DateTimePicker1.Text)
dr("DateRequired") = CDate(DateTimePicker2.Text)
dr("VendorID") = CInt(vendorbox.SelectedValue)
dr("HomeAddress") = txtApproved.Text.ToString
dr("ApprovedBy") = txtPrepared.Text.ToString
dr("TCAPO") = CInt(txtTCAPO.Text.Trim)
dr("CommentID") = CommentID
dr("TotalCost") = CDec(txtTotals.Text)
dr("TotalQuantity") = CInt(txtQtyTotal.Text)
' Add to the Rows collection or table .
dtProduction.Rows.Add(dr)
'Update the Production Table and then retrieve the ID created in this case
Production.Update(dtProduction)
 
 
Dollarjunkie

View 2 Replies View Related

How Can I Retrieve Data From A SQL Database Writing SQL Characters ( * , ? , [] ) In A Textbox Within My Form?

Nov 12, 2007



let's say I have a table named "myTable" in a SQL database:





UniqueID
FirstName
FamilyName

1
Elizabeth
Moore

2
Chris
Lee

2
Robert
McDonald's



I want to create a SQL query should contain a parameter for example:
SELECT * FROM myTable WHERE UniqueID = @TextBox OR FirstName = @TextBox OR FamilyName = @TextBox,


and when I type in my TextBox the ' * ' character, it should retrieve the whole table...

hope anybody understood, will be happy to explain more.

View 4 Replies View Related

Creating A View To Retrieve Data From More Than One Database Sql Server 2000

Jul 26, 2007

Hi everyone,


we have some reference tables in in a specific database. that other applications need to have access to them. Is it possible to create a view in the application's database to retrive data from ref database while users just have access to the application Database not the view's underlying tables?

Thanks

View 1 Replies View Related

Data Access :: Cannot Open Database After Changing Its Name And Change Back To Its Original Name

Sep 3, 2015

I cannot open now my database after changing it name from the folder where it is save and also changed back to its original name.Message recovery pending now is appearing as shown below.Any chance that I could recover my database back?

View 17 Replies View Related

Data Access :: How To Retrieve Remote Database Table Value To String Variable

May 28, 2015

I am using C# in  Visual Studio 2008 and remote database as sql server 2008 R2. I want to read remote database table's field value and i have to move that read value to string variable. how to do it. 

And my code is :

string sql = "Select fldinput from tmessage_temp where fldTo=IDENT_CURRENT('tmessage_temp')";
SqlCommand exesql = new SqlCommand(sql, cn);
exesql.CommandType = CommandType.Text;
SqlDataReader rd1 = default(SqlDataReader);
rd1 = exesql.ExecuteReader();

View 6 Replies View Related

4 Layered Web Application For Inserting Data Into A Database Using Sql Server As The Back End And A Web Form As The Front End Using C#

Dec 10, 2005

4 Layered Web Application for Inserting data into a database using sql server as the back end and a web form as the front end using C# .
Can someone provide with code as I am new to this architecture and framework.
Better send email.
Thanks In Advance,
A New Bie

View 1 Replies View Related

Reporting Services :: Map Parameter In Report Builder 3.0 Into Query To Retrieve Data From Database

May 29, 2015

Currently, I want to get images of an item in my report for illustration purpose.

Below is my query to get image for item 'GL-10000' in the database. However, I would like to pass a parameter value, '@sItem', from my report so that it would get all related pics of items.  

SQL Query:

Select top 1 item_picture_mst.picture from item_picture_mst
where item_picture_mst.item in (select item_all.item from item_all where item_all.item = 'GL-10000')
ORDER BY item_picture_mst.picture DESC;

View 3 Replies View Related

Refer To Webform Fields In Insert Statement

Aug 3, 2007

Can someone help with this? Let me know if what I'm trying to do is possible...

Here's code example:


@ClientID int,

@QuoteID int,

@Base real,

@One real,

@DwellingLimit real

AS

BEGIN

Insert Into tblOne(ClientID,QuoteID,GuideID,GuideRate,GuideMult,Premium)

Select @ClientID, @QuoteID, GuideID,GuideRate, @+"GuideMult"+,GuideRate*GuideMult

From tblTwo

Where Choose = 'True';

END


I need the value stored in tblTwo.GuideMult (ie. One, BaseRate) to be translated
into the numerical value shown on a webform (ie. @One, @BaseRate) and then
insert the numerical values into tblOne.GuideMult

Clear as mud? Does somebody have a better way to do this?

View 1 Replies View Related

Inserting Data To Text File From Database And Inserting Data Back To Database From Text File

Aug 7, 2007

Hello friends....
I am looking for 2 things(using c#.net or vb.net and sql svr 2000)
1.convert data from sql server 2000 database (say customers table from northwinds database) to a text file(separated by commas or just plain space)
2.Insert the data from text file back to database.
Can someone pls give me the detailed code to achieve this....really need this on urgent basis.......Thank You.

View 10 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

The Log File For Database 'Home_alone' Is Full. Back Up The Transaction Log For The Database To Free Up Some Log Space.

Feb 4, 2008



Hi all

Iam working in Prodcution ENV,Please help how make space


The log file for database 'Home_alone' is full. Back up the transaction log for the database to free up some log space.

View 10 Replies View Related

I Want To Revert Back To Original State Of Database Before I Performed Restore Database

Nov 15, 2006

Hello,i am in great trouble. I want to revert back to original state ofdatabase before i performed restore database on my sql server 2KDatabase. Accidently i didn't take backup of my Database and i didrestore, so is there any way to get the original state back of myDatabase?Any suggestion will be highly appriciated.Regards,S. Domadia.

View 2 Replies View Related

Edited Data Won't Propagate Back To The Database (VB 2005 Express &&amp; SQL Server 2005 Express)

Dec 11, 2006



Hi,

I'm trying to learn some VB programming with the VB 2005 Express Absolute Beginner Series video tutorials (which I think is great) and have come across a problem that I can't solve.

When I follow the instructions in Lesson 9 (Databinding Data to User Interface Controls) my application will display the data from the database correctly and I can edit it (and as long as the debugger is running the data remains changed). However, the changes won't propagate back to the database. I don't get any error messages but after I edit the data, save (with the save button on the BindingNavigator toolbar), and end debugging the data in my database remains unchanged. When I use a MessageBox to show how many rows where edited/updated in the

Me.myTableTableAdapter.Update(Me.myDatabaseDataSet.myTable)

I get the correct number back. I'm sure the problem is not due to coding errors since I've also tried running the accompanying Lesson 9 project file that can be downloaded from MSDN and the problem persists.

I'm using Windows XP SP2, SQL Server 2005 Express Edition and VB 2005 Express Edition. I've tried installing SQL Server 2005 Express with a number of different settings, including default settings, but it doesn't make any difference.

Would greatly appreciate any feedback on this as I'm keen to resolve this problem so I can get on with the next tutorial lesson.

Thanks,
Ieyasu

View 6 Replies View Related

Asp.net Page Is Unable To Retrieve The Right Data Calling The Store Procedure From The Dataset/data Adapter

Apr 11, 2007

I'm trying to figure this out
 I have a store procedure that return the userId if a user exists in my table, return 0 otherwise
------------------------------------------------------------------------
 Create Procedure spUpdatePasswordByUserId
@userName varchar(20),
@password varchar(20)
AS
Begin
Declare @userId int
Select @userId = (Select userId from userInfo Where userName = @userName and password = @password)
if (@userId > 0)
return @userId
else
return 0
------------------------------------------------------------------
I create a function called UpdatePasswordByUserId in my dataset with the above stored procedure that returns a scalar value. When I preview the data from the table adapter in my dataset, it spits out the right value.
But when I call this UpdatepasswordByUserId from an asp.net page, it returns null/blank/0
 passport.UserInfoTableAdapters oUserInfo = new UserInfoTableAdapters();
Response.Write("userId: " + oUserInfo.UpdatePasswordByUserId(txtUserName.text, txtPassword.text) );
 Do you guys have any idea why?
 
 

View 6 Replies View Related

Updating A Production Database With Back Up Of Development Database

May 11, 2007

Can someone provide a step by step tutorial for this? I'd like to safely update a database that is used for a website without much or any downtime.

View 1 Replies View Related

How?retrieve Data From Table1 Then Save The Retrive Data To Table2...

May 8, 2008

Good day., please help me,in a formview control, i set it in Insert Mode, so it should display info from table 1 but when i click on the insert button, it will insert it in table 2.btw, table 1 and table 2 are in the same database?? how about if they are not in the same database?how?please help me,Thanks.,SALAMAT PO., 

View 3 Replies View Related

Retrieve Text File Data In SSE For Data Acquisition System

Oct 24, 2007

Hey All,
I am developing a data acquistion system which monitors the amount of energy that a user consumes in different parts of a house and displays the information in real time on their computer screen. I am collecting the data through tranducers attached to the circuit breakers in the breaker box and sending the data to analog-to-digital converter channels in a MCU. I am retrieving the data from the serial port and storing it to a text file. Each line of data in the text file represents three fields which are separated by commas. I will be reading data from multiple data collection boxes so the first field is the unit number, the second fied represents the analog-to-digital converter channel number from each unit, and the third field is the data that is collected from the ATD channel. I am trying to use SSE to retrieve the data from the text file, and parse each line of data into individual columns in a databse. Then I want to be able to extract the data associated with a particular ATD channel number from the databse and display it in the appropriate text field on a windows form.
I've got the MCU programmed. I have no problem collecting the data from the serial port, and I can do the visual basic programming okay. I have absolutely no clue how to read the data into the database, continuosly read new values into the databse, and then access the stored data to update the text fields on the form. Please help if you can, I've been working on this specific problem for a couple of weeks and I'm not making any progress. Thanks.

View 3 Replies View Related







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