Programmatic Insert Into SQL Database

Nov 1, 2007

I have a page with over 20 Textbox and DDL controls and an upload  in various Divs and Panels (Ajax enabled) that are used for gathering user data. Some of the fields are mandatory and some optional.

In the Code behind (VB- I am a complete novice) On the submit button click event,  I iterate through the controls in the page and build an array with information from the controls that have data in them, (filtering out the non-filled textboxes, and DDLs).

All this works well, and I get an array called 'myInfo' with the columns with the control ID, and  control values 'rvalue' (as string), with the number of rows equal to the filled textboxes and DDLs.

I then step through the array and build a string with 'name=values' of all the rows in the myinfo array and email this as a message:

        ThisMessage = ""
        NoOfControls = myInfo.GetLength(0)
        For i = 0 To NoOfControls - 1           
                ThisMessage = ThisMessage & myInfo(i).ID.ToString & "=" & myInfo(i).rvalue.ToString & "; "
        Next

SendMail(email address, ThisMessage)

I also want to add this information to a database, appended by the IP address and datetime.now.

        Dim evdoDataSource As New SqlDataSource()
        evdoDataSource.ConnectionString = ConfigurationManager.ConnectionStrings("SQLConnectionStringCK").ToString
        evdoDataSource.InsertCommandType = SqlDataSourceCommandType.Text
        

        Dim InsertMessage As String = """INSERT INTO evdoData ("
        NoOfControls = myInfo.GetLength(0)

        Dim k As Integer
        For k = 0 To NoOfControls - 1  
                InsertMessage = InsertMessage & myInfo(k).ID.ToString & ", "
        Next

        InsertMessage = InsertMessage & "IPNo, DateEntered) VALUES ("

        For k = 0 To NoOfControls - 1       
                InsertMessage = InsertMessage & "@" & myInfo(k).ID.ToString & ", "
        Next
        InsertMessage = InsertMessage & ", @IPNo, @DateEntered" & ")"""
       
       evdoDataSource.InsertCommand = InsertMessage

I then similarly iterate through and do the insertparameters.

Now here is the rub- (My all too often DUH moment!)

When I look at the insertmessage in debug (and to be sure- I also show the insert string on a temporary debug label on the page), The insertmessage looks fine:

"INSERT INTO EvdData (FirstName, Age, Email, Phone, Country, City, IPNo, DateEntered) VALUES (@FirstName, @Age, @Email, @Phone, @Country, @City, , @IPNo, @DateEntered)"

However when the above code(evdoDataSource.InsertCommand = InsertMessage) is run, I get an error - the message with the error is:

The identifier that starts with 'INSERT INTO ModelData (FirstName, Age, Email, Phone, Country, City, IPNo, DateEntered) VALUES (@FirsteName, @Age, @Email, @Phone,' is too long. Maximum length is 128

EH?  When I actually copy the InsertMessage from the debug window and paste it manually after the command "evdoDataSource.InsertCommand = " It works, and I get the data inserted into the table..

-It would seem that I am probably missing something obvious in my complete "noviceness" . HELP! (oh and thanks a bunch in anticipation)

 _____________________________________________________________________________________________________________________

Its Easy --------------------------When you know How.  Meanwhile Aaaaaaaaah .

View 4 Replies


ADVERTISEMENT

Programmatic Inspection Of A Dump?

May 21, 2004

I need to set up a job to allow users to restore their databases, on SQL Server 2000 SP3. The idea is that a user inserts a record into a table, identifying the dump they want to load. (They can only restore their own account.) A job picks up this record, restores the database, and notifies the user as appropriate.

My part of this is writing the procedure that the job executes, including the dump restore. Part of that is getting each dump's file groups (data, index, and log) into the proper locations for this server and this user.

Essentially, I need to be able to access the results of 'load filelistonly' from a cursor. How do I access the file list?

View 2 Replies View Related

Create DTS PACKAGE Programmatic

Nov 24, 2006

Hi guys..!!

i am working on Dynamic creation of DTS-packages in C#.NET 2005(sql server 200)

but i not must create package in Sql Server.
but i cant...

can i do ?
any ideas ??

thx...

View 3 Replies View Related

Programmatic Use Of SQLDataSource Not Returning Dataview

Sep 4, 2007

I am creating an ad-hoc reporting module for my website.  The user may select a list of columns and specify the WHERE for the report.  I build the select statement and the where statement and pass the info to a stored procedure.  The stored procedure accepts 3 select parameters and a 3 wherestmt parameters.  I finally got the SQLDatasource to work by setting the parameter values in the Selecting method of the SQLDatasource.  Binding it to a gridview shows me all my values.  Now, I am trying to programmatically call the select method of the SQLDatasource so I can get a dataview or datareader to manipulate further.  I am getting an null back when I call the select method.  Any ideas why? or a workaround?
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:AssetMgmtRWConnectionString %>"SelectCommand="getAdhocRptData" SelectCommandType="StoredProcedure" DataSourceMode="DataReader">
<SelectParameters>
<asp:Parameter Name="strSelect" Type="String" />
<asp:Parameter Name="strSelect2" Type="String" />
<asp:Parameter Name="strSelect3" Type="String" />
<asp:Parameter Name="strWhere" Type="String" />
<asp:Parameter Name="strWhere2" Type="String" />
<asp:Parameter Name="strWhere3" Type="String" />
<asp:Parameter Name="bitDebug" Type="Boolean" />
</SelectParameters>
</asp:SqlDataSource>
 
<VB Code>Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Getting an error that the object is null? why is the above code not returning any data?
'Tried using a datareader and datasource.Dim rptview As IDataReader = CType(SqlDataSource1.Select(DataSourceSelectArguments.Empty), IDataReader)
If rptview.Read Then
lblMsg.Text = "Got Rows"
End If
End Sub
Protected Sub SqlDataSource1_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles SqlDataSource1.Selecting
'For this sp, need to set each paramater even if it is not being used. Setting it in the wizard
'does not work. Need to be set programmatically.
e.Command.Parameters("@strSelect").Value = "p.field1, p.field2 "
e.Command.Parameters("@strSelect2").Value = "s.field1, s.field2"
e.Command.Parameters("@strSelect3").Value = "a.field1, a.field2, a.field4, a.field5"
e.Command.Parameters("@strWhere").Value = "p.field3 is not null and a.field5 is null"
e.Command.Parameters("@strWhere2").Value = "'"
e.Command.Parameters("@strWhere").Value = ""
e.Command.Parameters("@bitdebug").Value = False
End Sub
 
thanks for any help.
 

View 2 Replies View Related

Programmatic Access To Sensitive Data

Jan 18, 2007

Hello,

I'm developing custom SSIS task (control flow component) which offers usert to choose ADO.NET connection.

I want to use this connection in my code and access SQL server.

There is no any problem unless connection is with IntegratedSecurity = true.

But, when user chooses to set username and password, I can not access password because it is not present in the connection string as sensitive information.

Package.DTSProtectionLevel is set to EncryptAllWithUserKey

I need to programmaticaly access to password, but I don't know which class to use from DTS (SSIS) object model.



Any help?

Thanks, Borko



View 1 Replies View Related

DTSTransform.DataConvert Programmatic Access?

Jan 27, 2006

I am trying building a package from code. I have been able to follow the SSIS samples and build my control flow with foreach loop and SQL Commands pretty easily.

The data flow has been a different story, I am struggling with input and output columns. I trying to read from a flatfile, convert data, perform a lookup, and update or insert based on the results of the lookup. I was able to build this package in the designer and it works just as I want, but I am having problems duplicating the data flow in the code.

I was able add the flatfile, data conversion, and insert controls on the data flow and linked them together. However, I cannot figure out how get the input columns in the data convert object to become selected and generate the converted output columns.

I have tried to refresh metadata and mappings column, but to no success. The only custom property for this component seems to be SourceInputColumnLineageId, but I cannot figure how to set it. Can someone give me nudge or push in the right direction?

Here is what is left of my code:

IDTSComponentMetaData90 convert= dataFlow.ComponentMetaDataCollection.New();
convert.ComponentClassID = "DTSTransform.DataConvert";

// Get the design time instance of the component and initialize the component
CManagedComponentWrapper instance = convert.Instantiate();
instance.ProvideComponentProperties();

IDTSPath90 path = dataFlow.PathCollection.New();
path.AttachPathAndPropagateNotifications(srcComponent.OutputCollection[0], onvComponent.InputCollection[0]);

// Reinitialize the metadata.
instance.AcquireConnections(null);
instance.ReinitializeMetaData();
instance.ReleaseConnections();

// Iterate through the inputs of the component.
IDTSVirtualInput90 vInputLkUp = convert.InputCollection[0].GetVirtualInput();
foreach (IDTSVirtualInputColumn90 vColumn in vInputLkUp.VirtualInputColumnCollection)
{
IDTSInputColumn90 col = instance.SetUsageType(convert.InputCollection[0].ID, vInputLkUp, vColumn.LineageID, DTSUsageType.UT_READONLY);
//instance.SetInputColumnProperty(convert.InputCollection[0].ID, col.ID, "SourceInputColumnLineageId", 1);
}






View 1 Replies View Related

Simulataneous Programmatic And Declarative Access To SQLDataSource Data

Apr 22, 2006

Hi,
Is there a way to programmatically access the results of an SQLDataSource control select at the time it is binding to a DetailView? There are some fields in the data results I do not want to render to the page, but I still need for other stuff.
I know I can programmatically invoke a select method, but since it is selecting anyway for binding to the DetailView it would be better to get all the data in one swoop.
Thanks in advance for any assistance you could provide.
Best Regards,
Brett 

View 4 Replies View Related

SQL Server 2014 :: Programmatic Creation Or Modification Of SSIS

May 21, 2015

I'm trying to create an SSIS package that will do a straight data copy between databases. The problem is that the underlying schema of the origin may change and the requirement is that the transfer be table driven. i.e. the tables that are copied are listed in a table and there should be no human intervention when the schema changes.

I'm moving data between SQL Server and SQL Azure, so backup and restore doesn't work. Has to be an SSIS package.

What's the best way to deal with a changing schema in an SSIS package? Can I delete and rewrite the underlying XML for any tables that change? Do I need to do it programmatically with C#? Do I need to create the package from scratch each time?

View 2 Replies View Related

Peer-to-Peer Replication (Programmatic Control And Setup)

Feb 7, 2007

I have reviewed the BOL documentation on how to configure Peer-to-Peer replication via T-SQL and how to use the Replication Wizard to implement replication.

What I would like to find out is how do I configure the peer-to-peer replication process to use an existing column on a table that contains a GUID instead of creating an extra column with a uniqueidentifier GUID value. When you use the Wizard each table article has this extra column added to it.

I don't seem to be able to find it in the books-on-line. Can some one point me to the correct article or BOL page.

Thank you.

...cordell...

View 1 Replies View Related

Can I Insert/Update Large Text Field To Database Without Bulk Insert?

Nov 14, 2007

I have a web form with a text field that needs to take in as much as the user decides to type and insert it into an nvarchar(max) field in the database behind.  I've tried using the new .write() method in my update statement, but it cuts off the text after a while.  Is there a way to insert/update in SQL 2005 this without resorting to Bulk Insert? It bloats the transaction log and turning the logging off requires a call to sp_dboptions (or a straight-up ALTER DATABASE), which I'd like to avoid if I can.

View 6 Replies View Related

DB Design :: Buffer Database - Insert Information From Partners Then Make Update To Main Database

Oct 29, 2015

I actually work in an organisation and we have to find a solution about the data consistancy in the database. our partners use to send details to the organisation and inserted directly in the database, so we want to create a new database as a buffer database to insert informations from the partners then make an update to the main database. is there a better solution instead of that?

View 6 Replies View Related

Integration Services :: How To Insert / Update Table From Database 1 To Database 2

Oct 26, 2015

I am using two database server. Both are sql server. 

My task is :I want to insert data from server 1 table to server 2 table and update same when modified the existing data from server 1. is it possible to do the integration in single package.

I know to do insert and update seperately by ssis but need to do same with single task. 

View 5 Replies View Related

SQL Express Database Table Data Insert Into Another Database

Apr 15, 2007

Hi,

I have two SQL Express database and I want to do two things. One is to transfer a table over to the other database. Two, move the files from one table in one database to another. Please let me know when you get a chance.

Thanks,

Kyle

View 8 Replies View Related

Can Connect To Database, But How Do I Insert Values Into SQL Database?

Jun 14, 2006

I was able to connect to the SQL Database Pension with table clients with table values: ID, State, Name.'Create(connection)Dim conn As New Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)'open connectionconn.Open()However, I'm not sure how to insert a new row with an incremental ID number and a new State and Name.Sorry, I'm really new with VWD.

View 1 Replies View Related

How To Insert One Database Table To Another Database ?

May 22, 1999

Hi guys,

I have two sql servers one is Nt server another one is Nt workstation,i am able to admin from both sides.but i don't know how to insert/update one database table to another database table, pls. give me some ideas for this.

Thanks in Advance
Nellai

View 1 Replies View Related

How To Do Insert In Another Database When The Database Name Is A Variable

Mar 19, 2008

Hi,

We have different databases on the same server: Whrs001, Whrs002, etc. All databases have the same structure.

Suppose i have a table "location"
create table location
( location_id int not null primary key,
location_name varchar(50) not null )

I need to inserts data in "location" tables of different databases. But these inserts needs to be across databases. For example from the "Whrs003" database I need to insert data (location_id=123, location_name='markham') in "location" table of "Whrs001" database.

So my thinking is to defined a stored proc which has database name as an argument:
create procedure location_insert
@a_database_name varchar(100),
@a_location_id int,
@a_location_name varchar(50)
as
...

So for the above example the call will be :
exec location_insert 'Whrs001', 123, 'markham'


What would be the actual insert statement in this case? And what things i neeed to take care fo to make sure it always execute successfully?

Thanks

View 5 Replies View Related

Insert Data One Database To Other Database

May 7, 2007

hi

i am using this queries is

Insert into excelb.B.dbo.Emp(Employee_Name,Emp_addr) Values (@Employee_Name,@Emp_Addr) select * from excelb.A.dbo.Emp



excelb - server name

now my problem is a server to another server insert the data that not acces the data and i am using different password the servers- but same pasword are insert the data

plz help me



bye

elango

View 4 Replies View Related

Cannot INSERT INTO SQL Database.

Jul 17, 2006

I'm not sure what the problem is.  I am not getting any errors, but I can't get this code to insert into my SQL db.  I've checked the permissions on the database and table, and it looks fine. 
Is there something wrong with this code?  I'm trying to switch from VB to C#, so it's still new to me.  I've used the connection string in another APP so I know it works.
If I'm not getting an asp.net error, does that point to a problem with the DB?  Thanks.
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection Conn;SqlCommand Command;
Conn = new SqlConnection();Conn.ConnectionString = ConfigurationManager.AppSettings["ConnectionString"];Command = new SqlCommand();
Command.CommandText = "INSERT INTO [tbl_Test] ([test_name], [test_email]) VALUES (@test_name, @test_email)";
Command.CommandType = CommandType.Text;Command.Connection = Conn;Command.Parameters.Add("test_name", tbName.Text);Command.Parameters.Add("test_email", tbEmail.Text);
try
{
Command.Connection.Open();Command.ExecuteNonQuery();
}
catch (Exception ex)
{
lError.Text = ex.Message;
}
finally
{
Command.Connection.Close();pSubscribe.Visible = false;lThanks.Visible = true;
}

View 3 Replies View Related

How Do I Do A Look Up And Then Insert Into The Database,

Apr 10, 2008

Hi,
 I am getting xml data from a webservice.. and in that xml data there in field called State but on the system that we are getting the data from has a text box where the user can enter NC or North carolina.. But our system is set up to just accept a two letter character. like NC.. So suppose if the user sends North carolina instead of NC the nothing takes places on our system cause we get an error saying that Two many characters..
 
SO i am looking for ideas that will solve this problem but have the state column accept just 2 letters
any help will be appreciated
KAren

View 2 Replies View Related

Insert ' Into A Database

Jun 15, 2008

My problem is that when I add a question and the question contains a ' (For instance: I'm going to the store), an error message shows up for 'm from I'm. Here is my code.             SqlConnection myConnection = new SqlConnection("Server=???;Database=???;Persist Security Info=True;User ID=???;Password=???");            SqlCommand insertCmd = new SqlCommand();            insertCmd.CommandType = System.Data.CommandType.Text;            insertCmd.CommandText = "INSERT INTO TestQuestions (unitChapterID, question, answerA, answerB, answerC, answerD, answer) VALUES ("                + int.Parse(DropDownList3.Text.ToString()) + ", '"                + questionAddBox.Text.ToString() + "', '"                + aAddBox.Text.ToString() + "', '"                + bAddBox.Text.ToString() + "', '"                + cAddBox.Text.ToString() + "', '"                + dAddBox.Text.ToString() + "', '"                + answerAddBox.Text.ToString() + "')";            insertCmd.Connection = myConnection;            myConnection.Open();            insertCmd.ExecuteNonQuery();            myConnection.Close();

View 2 Replies View Related

Help Me Pls - With Database And Insert Statement

Aug 27, 2006

I Have an error:  Server Error in '/quanlythietbi' Application. INSERT statement conflicted with COLUMN FOREIGN KEY constraint 'FK_yeucau_nhanvien'. The conflict occurred in database 'equipment', table 'nhanvien', column 'manv'. The statement has been terminated. Source Error: Line 129:mycommand.Parameters.Add(new SqlParameter("@noidung_yc1",System.Data.SqlDbType.Text));
Line 130:mycommand.Parameters["@noidung_yc1"].Value = TextBox1.Text;
Line 131:int i = mycommand.ExecuteNonQuery();
Line 132:if (i>0)
Line 133:{and this is my code:string sqlstring = "Select * from yeucau where ngayGiaiQuyetxong='"+ Label8.Text +"' and date_yc='" + Label7.Text + "' and manv_yc='"+ TextBox2.Text + "' and noidung_yc='"+ TextBox1.Text+ "'";myconnection = new SqlConnection(stringconn);mycommand = new SqlCommand(sqlstring,myconnection);myconnection.Close();myconnection.Open();mycommand = new SqlCommand(insertquery,myconnection); mycommand.Parameters.Add(new SqlParameter("@ngayGiaiQuyetxong1",System.Data.SqlDbType.Char,10));mycommand.Parameters["@ngayGiaiQuyetxong1"].Value = Label8.Text;mycommand.Parameters.Add(new SqlParameter("@date_yc1",System.Data.SqlDbType.SmallDateTime));mycommand.Parameters["@date_yc1"].Value = Label7.Text;mycommand.Parameters.Add("@manv_yc1",System.Data.SqlDbType.Char,10);mycommand.Parameters["@manv_yc1"].Value = TextBox2.Text;mycommand.Parameters.Add(new SqlParameter("@noidung_yc1",System.Data.SqlDbType.Text));mycommand.Parameters["@noidung_yc1"].Value = TextBox1.Text;int i = mycommand.ExecuteNonQuery();if (i>0){lbcheck.Text = "Ä?ã Cập Nhật Yêu Cầu.";} --------------------------------------------------------------------------------------------------------------------------------I don't know what I must do to repair it :(

View 2 Replies View Related

Insert Data Into Database

Feb 27, 2007

What is wrong with this code the dropdowlist mainlyusing System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class NewAccount : System.Web.UI.Page{    protected void Page_Load(object sender, EventArgs e)    {    }    protected void NaccountButton_Click(object sender, EventArgs e)    {        if (Page.IsValid)        {            //Define data objects            SqlConnection conn;            SqlCommand comm;            //read from web config            string connectionString = ConfigurationManager.ConnectionStrings["OneBank"].ConnectionString;            //Initialize connection             conn = new SqlConnection(connectionString);            //create command            comm =new SqlCommand(                "INSERT INTO Customer (FirstName, LastName, Street, City, State," +                 "Zip, Phone, Payee,AccountType)" +                 "VALUES(FirstName, LastName, Street, City," +                 "State, Zip, Phone, Payee,AccountType)", conn);            //add parameters            comm.Parameters.Add("@FirstName", System.Data.SqlDbType.NVarChar, 50);            comm.Parameters["@FirstName"].Value=Firstname.Text;            comm.Parameters.Add("@LastName", System.Data.SqlDbType.NVarChar, 50);            comm.Parameters["@LastName"].Value=lastname.Text;            comm.Parameters.Add("@Street", System.Data.SqlDbType.NVarChar, 50);            comm.Parameters["@Street"].Value=street.Text;            comm.Parameters.Add("@City", System.Data.SqlDbType.NVarChar, 50);            comm.Parameters["@City"].Value=city.Text;            comm.Parameters.Add("@State", System.Data.SqlDbType.NVarChar, 50);            comm.Parameters["@State"].Value=state.Text;            comm.Parameters.Add("@Phone", System.Data.SqlDbType.Int);            comm.Parameters["@Phone"].Value=phone.Text;           comm.Parameters.Add("@AccountType", System.Data.SqlDbType.NVarChar, 50);           comm.Parameters["AccountType"].Value = dropdownlist1.SelectedValue.ToString();            //Enclose database in try catc finally            try            {                //open connection                conn.Open();                //execute the command                 comm.ExecuteNonQuery();                //reload query                Response.Redirect("NewAccount.aspx");            }            catch            {                //Display error               Errormessage.Text=                    "Error submitting request!";            }            finally            {                conn.Close();            }        }    }}
 
This is the table where thisis going
customer                       -------------                     customerID pk generated automatically firtsname                            lastname                             street                                                               city                                                                       statezipphoneaccountType

View 3 Replies View Related

Using Sql To Insert Into Database Problem

Oct 17, 2007

I am creating a zipcode search radius function for my site, and I downloaded a .sql file containing the info I need.
The problem is that on the latitude and longitude colunm it needs to be entered with a decimal such as 73.5598.
If the column type is Decimal I can manually enter it, but when it's inserted via the script it rounds the number ie. 73
The only type I can get to accept the .sql script as is, is nvarchar, but then it has trouble converting to a numeric for the radius.
This is the script I am entering:
INSERT INTO classifieds_ZipCodes (zip, city, state, state_name, longitude, latitude, rlong, rlat) VALUES ('00501', 'HOLTSVILLE', 'NY', 'New York', '73.0456', '40.8153', '1.27479232112', '0.712308900524') 
Any ideas??
Keep in mind there are over 42,000 zipcode entries
Thank you
Daniel Meis
 

View 4 Replies View Related

Insert A Image Into A Sql Database

Nov 27, 2007

Hello All,
I want to insert a images into a database and these images save into a one perticular folder.
and i want to use these Images into some Diffrent Diffrent area
 
please help me
ashwani

View 1 Replies View Related

Insert Time To Database

Jan 31, 2008

Hello,
I have a textbox on my formview which brings in a time from an sqldatasource. The time is displayed as 09:00:00 in the sql select statement i have a convert function - CONVERT (varchar, Time, 8)
I am trying to alter the text e.g change to 09:30:00 and send it back to the database however i am having a lot of problems with that.
Anyone know what i have to do to sort this. I think it might be something to do with the sql insert or the insert parameters as i dont know how to change the time String back to DateTime.
Any help appreciated. Thanks in advance Mike.

View 1 Replies View Related

Insert Date Into SQL Database

Mar 4, 2008

This is a simple n00b question, but how can I insert the current date time into a datetime field in a database when submitting a form?
 I'm using the SQL DataSource control to do the inserting: <asp:SqlDataSource ID="SqlDataSourceMiguel" runat="server" ConnectionString="<%$ ConnectionStrings:SQLDataConnectionToInsertMiguelsTips %>"
 
InsertCommand="INSERT INTO tblMig(TipTitle, TipBody, TipExcerpt,TipDate) VALUES (@Title,@Body,@Excerpt,@varDate)">
<InsertParameters><asp:ControlParameter ControlID="ctl00$ContentPlaceHolder3$txtTitle" Name="Title" PropertyName="Text" /><asp:ControlParameter ControlID="ctl00$ContentPlaceHolder3$txtBody" Name="Body" PropertyName="Text" /><asp:ControlParameter ControlID="ctl00$ContentPlaceHolder3$txtExcerpt" Name="Excerpt" PropertyName="Text" /><asp:ControlParameter ControlID="ctl00$ContentPlaceHolder3$txtDateNow" Name="varDate" /></InsertParameters></asp:SqlDataSource>
 Thank You

View 4 Replies View Related

Insert Into, One-to-many Relationship Database

Apr 20, 2008

I have a MS-SQL 2005 database that is in a one-to-many relationship that is like this:
Table: Company
CompanyID, company name, address, city, etc.
Table Service States:
CompanyID, StateID
Table: States
CompanyID, StateID, State
The result is that you can have multiple states that are serviced assigned to any particular company.
Then in my ASP, I have a form for adding new companies to the database. On this form I have text boxes for Company name, Address, etc. Then for adding the states that are serviced, since you can have multiple states that serviced I decided to put in a Grid. This works fine if I'm editing the Company since the CompanyID already exists, but when I'm adding a new company, I can't INSERT INTO the Table Service States, since I don't know what the CompanyID is yet.
What would be the best way to handle this situation? I could probably put in a a ListBox with a Dropdown, then a little button with an add, add the items to the Listbox, then do an Insert on the Table Company, grab the companyID, then insert the items from the combobox.
I'm wonder if anyone has any better suggestions or ideas to handle this.
Thanks,
marly
 

View 1 Replies View Related

How To Insert A Tables From One Database To Another

Apr 22, 2008

Hi i want to insert a tables from one database to another based on unique key

View 2 Replies View Related

Insert Date Into Database

Mar 13, 2004

I am trying to insert the current date into my database here is the code I am using

sql = "Insert into tblguestbook(date, name, city, state, email, Url, Comments)Values ('"
sql = sql & Request.Form(Now) & "','"
sql = sql & Request.Form("nametxt") & "','"
sql = sql & Request.Form("citytxt") & "','"
sql = sql & Request.Form("statetxt") & "','"
sql = sql & Request.Form("emailtxt") & "','"
sql = sql & Request.Form("urltxt") & "','"
sql = sql & Request.Form("commentstxt") & "');"



When I review my table the only date that will go into it is 1/1/1900.

Please help

View 6 Replies View Related

How To Insert Xml Data Into Database

Jul 21, 2005

I have a table changereport and network info.i  insert a record with date of insertion plus chagereport id.then I have a xml file
<ChangeReport> <Network-Info>  <Version> 2.0</Version>  <Highest-Ver> 2.0</Highest-Ver>  <Description> WinSock 2.0</Description>  <System-Status> Running</System-Status>  <Max> 2.0</Max>  <IP-address> 192.168.142.1</IP-address>  <Domain-Name> samin</Domain-Name>  <UDP-Max> 2.0</UDP-Max>  <Computer-Name> SAMIN</Computer-Name>  <User-Name> samin</User-Name> </Network-Info></ChangeReport>
I want's to insert a record in network info table where field name are nodes name data should be the one against those nodes in xml file .How can I do it I am using sql server
 

View 2 Replies View Related

Insert Data Into SQL Database

Feb 21, 2006

What have I done wrong with this script?I'm getting an error The ConnectionString property has not been initialized.



Description: An
unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the
error and where it originated in the code.

Exception Details: System.InvalidOperationException: The ConnectionString property has not been initialized.

Source Error:




Line 73: myCommand.Parameters.Add(New SqlParameter("@Activationcode", SqlDbType.nVarChar, 50))Line 74: myCommand.Parameters("@Activationcode").value = activecode.valueLine 75: myCommand.Connection.open()Line 76: tryLine 77: myCommand.ExecuteNonQuery()





Dim loConn as New SqlConnection(ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_HWB"))Dim myCommand as SqlCommandDim InsertCmd as StringinsertCmd = "insert into Login values (@Username, @Password, @email, @Activationcode);"myCommand = New SqlCommand(InsertCmd, loConn)myCommand.Parameters.Add(New SqlParameter("@Username", SqlDbType.nVarChar, 50))myCommand.Parameters("@Username").value = Username.valuemyCommand.Parameters.Add(New SqlParameter("@Password", SqlDbType.nVarChar, 50))myCommand.Parameters("@Password").value = Password.valuemyCommand.Parameters.Add(New SqlParameter("@email", SqlDbType.nVarChar, 50))myCommand.Parameters("@email").value = email.valuemyCommand.Parameters.Add(New SqlParameter("@Activationcode", SqlDbType.nVarChar, 50))myCommand.Parameters("@Activationcode").value = activecode.valuemyCommand.Connection.open()myCommand.ExecuteNonQuery()myCommand.Connection.Close()

View 1 Replies View Related

Help! Insert A Record Into SQL Database With ASP.net And C#

May 29, 2006

I'm trying to make a website that people can upload file to the server, then the webpage will automatically insert the username and the file name into the database. I have thought about this for couple days but still got nothing. can some one help me?
can some one post a very simple aspx file that can insert a record to the sql database with C#? Not the code that generated by ASP.net 2.0!
I want to see how to access the database manually.
Thank you.

View 2 Replies View Related

Using A Trigger To Insert Into A Different Database.

Feb 3, 2005

Hi, does anyone know what syntax I have to use if I want to use a trigger to insert into a different database. This is the code I have I'm just not sure how to get it to identify a different database.

CREATE TRIGGER History_replication ON [dbo].[History]
FOR INSERT
AS
INSERT [dbo].[History] (this one shoul dbe on the History_copy db)
(workdone,error)
SELECT workdone,error
FROM [dbo].[History]


Thanks Ed

View 4 Replies View Related







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