Insert Data Into SQLExpress

Dec 3, 2005

I'm trying to insert data into my local SQLExpress database by using on buttonclick from a asp.net page.   I run the page, hit submit and I check my database and there's no data entered.  Does the following code look correct or do I need to look at other things...

Thanks in advance!

 

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

If Not Page.IsPostBack Then



Dim mycommand As SqlCommand

Dim myconnection As New SqlConnection

Dim insertCmd As String

Dim guidResult As String = System.Guid.NewGuid().ToString()

Dim isAffected As Integer



 

myconnection = New SqlConnection()

myconnection.ConnectionString = "Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|ASPNETDB.MDF;Integrated Security=True;User Instance=True"

myconnection.Open()

insertCmd = "Insert Into [tbl_Messaging] ([UserName], [Admired], [message], [messageID], [datesent]) Values (@Username, @Admired, @message, @messageID, @dateSent)"

mycommand = New SqlCommand()

mycommand.CommandType = CommandType.Text

mycommand.CommandText = insertCmd

mycommand.Parameters.Add("@username", SqlDbType.VarChar).Value = Profile.Username

mycommand.Parameters.Add("@admired", SqlDbType.VarChar).Value = TextBox1.Text

mycommand.Parameters.Add("@message", SqlDbType.VarChar).Value = TextBox2.Text

mycommand.Parameters.Add("@messageid", SqlDbType.UniqueIdentifier).Value = guidResult

mycommand.Parameters.Add("@datesent", SqlDbType.SmallDateTime).Value = DateTime.Today.ToShortDateString

isAffected = mycommand.ExecuteNonQuery()

myconnection.Close()



End If

End Sub

View 1 Replies


ADVERTISEMENT

HELP - Insert Record SQLExpress Database

Feb 26, 2007

Hi! i ask you some help..I should build a simple INSERT FORM in a SQLExpress database..
but clicking ADD I have this error :
 
Incorrect syntax near '='.
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.Data.SqlClient.SqlException: Incorrect syntax near '='.Source Error:



Line 38: conDatabase.Open()
Line 39:
Line 40: cmdInsert.ExecuteNonQuery()
Line 41:
Line 42: conDatabase.Close()
some solution?
the source code:
 
<%@ Page Language="VB" Debug="true"%>
<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.SqlClient"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Sub Button_clic(ByVal s As Object, ByVal e As EventArgs)
Dim conDatabase As SqlConnection
Dim strInsert As String
Dim cmdInsert As SqlCommand
Dim myExecuteQuery As String
Dim myExecuteCmd As SqlCommand
 
conDatabase = New SqlConnection("Data Source=.SQLEXPRESS;AttachDbFilename=C:Inetpubwwwroot esiApp_Datadatabase.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")
 
strInsert = "Insert pubblicazioni (Nome, Cognome, Titolo) Values = (@Nome, @Cognome, @Titolo) "
cmdInsert = New SqlCommand(strInsert, conDatabase)
cmdInsert.Parameters.Add("@Nome", txtNome.Text)
cmdInsert.Parameters.Add("@Cognome", txtCognome.Text)
cmdInsert.Parameters.Add("@Titolo", txtTitolo.Text)
 
conDatabase.Open()
cmdInsert.ExecuteNonQuery()
conDatabase.Close()
 
Response.Redirect("success.html")
End Sub
 
 
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>iNSERIMENTO</title>
<LINK href="mauro.css" rel=stylesheet>
 
<script type="text/javascript" language="javascript">
<!--
function popopen(){
window.open("upload/upload.aspx","name"," toolbar=no,directories=no,menubar=no,width=300,height=300,top=100,left=150,resizable=no,scrollbars=yes");
}
// -->
</script>
 
 
 
</head>
<body bgcolor="#DFE5F2" style="font-size: 12pt">
<form id="form1" runat="server">
<div>
&nbsp;<asp:Label ID="Label1" runat="server" BackColor="#8080FF" BorderColor="Black"
ForeColor="Black" Height="29px" Text="FORM INSERIMENTO DOCUMENTO" Width="371px" Font-Bold="True" Font-Names="Verdana" Font-Size="14pt" Font-Underline="True"></asp:Label><br />
<br />
<br />
<B><span style="font-family: Verdana">NOME&nbsp; </span></B>
<asp:TextBox ID="txtNome" runat="server"></asp:TextBox>
&nbsp; &nbsp; <B><span style="font-family: Verdana">COGNOME&nbsp; </span></B>
<asp:TextBox ID="txtCognome" runat="server"></asp:TextBox><br />
<br />
<B><span style="font-family: Verdana">TITOLO&nbsp; </span></B>
<asp:TextBox ID="txtTitolo" runat="server"></asp:TextBox><br />
<br />

 
 
 <a href="javascript:popopen()">CARICA DOCUMENTO</a><br/><br />
 
 
 
 
 
<asp:Button ID="Button1" runat="server" OnClick="Button_Clic" Text="ADD" Font-Bold="True" Font-Names="Verdana" Font-Size="12pt" Width="160px" /></div>
<br><br>
</form>
 
</body>
</html>

View 2 Replies View Related

Problem To Insert A Double Value Into Sqlexpress

Jan 25, 2006

Hi..
I have a small problem to insert a double value into a sqlexpress database:Her is the problem example
dblValue = 5.5int = 1conn.Open()Dim query As String = "INSERT INTO testtable VALUES(" & intValue & "," & dblValue & ",1.2)"Dim command As SqlCommand = New SqlCommand(query)Command.Connection = conncommand.ExecuteNonQuery()The table has tre columns: int, decimal, decimal."INSERT INTO testtable VALUES(1,5,5,1.2)"The problem is that ,in the sqlcommand, the dblValue er transformed from 5.5 to 5,5, so it seems that i am going to insert 4 values, 1 - 5 - 5 and 1.2. Why are the dblvalue transformed and not the value 1.2? How do I avoid this problem?
 

View 1 Replies View Related

Can't Start SQLEXPRESS So That I Can't Install Latest SQLEXPRESS Security Updates.

Mar 13, 2007

I can't start SQLEXPRESS.

The SQL ERRORLOG shows: Error is 3414, Severity 21, State 2 and says: "An error occurred during recovery, preventing the database 'model' (database ID 3) from restarting." Just prior to this, I get a warning: "did not see LP_CKPT_END".

Any thoughts why this might be and how I can fix this?

View 3 Replies View Related

Installing SqlExpress (Advanced Services) Will This Break Existing SqlExpress?

Sep 21, 2006

hiya,

I have sqlExpress and sqlServerManagementStudio on my XP pro box.

Will the installation of sqlExpress (Advanced Services) cause any problems?IS thereanything that I shold be aware of in advance?

many thanks,

yogi

View 3 Replies View Related

How To Install Windows Application(C#) With SQLExpress In A System Which Is Having SQLExpress Already?

Jan 19, 2007

Hi All,

I have created an installation application which will install the application with SQL Express and .NET Framework 2.0.

If i install this application in a Fresh system(i.e which is not having SQL Express), it is installing the application with new database instance successfully.

But if i try to install the same in a system which is already having SQL Express, throwing "Object reference exception" because it is not able to create the new database instance.

Can anybody help me out .

Regards,

Doppalapudi.

View 2 Replies View Related

Data Changes In SQLExpress Not Committed?

Aug 2, 2006

Hello,
I am developing an application with a SQLExpress database. The database contains a very simple table, and I have added a Dataset object to the solution, and generated a plain Adapter object in the Dataset (using the standard VS wizard capabilities) to operate on one of the tables in de database. Just plain SELECT, INSERT operations, etc.
Strange thing is, the data changes caused by the adapter's generated Insert command (which will call the INSERT statement on the database) are only visible while the application runs (or so it seems). For example:
- I start off with the table containing 2 records, and start debugging- perform a COUNT within the code: 2 records- call the Insert function once from code- perform a COUNT within the code: 3 records- stop debugging- inspect the table: the 3rd record doesn't exist, just the 2 recordsSo, it seems that the changes don't get committed, although I am not sure it is a transaction/commit problem. I haven't been able to figure out what I can do to fix this. I have used adapters before on a SQL database, no problems there. Any comments appreciated.
Cheers, JP

View 1 Replies View Related

Sqlexpress Installer Doesn't Believe Sqlexpress Has Been Uninstalled

Mar 21, 2006

Because of numerous problems trying to get sqlexpress working, I uninstalled it with the intention of reinstalling (via Add or Remove Programs). However, now when I try to reinstall it, I get a message that the I am not making a changes so it won't let me install it.

I do have sql server 2005 developer's edition installed; is that the reason? and does that mean I cannot have both installed on the same machine?

View 1 Replies View Related

SQL Server 2008 :: Insert Data Into Table Variable But Need To Insert 1 Or 2 Rows Depending On Data

Feb 26, 2015

I am writing a query to return some production data. Basically i need to insert either 1 or 2 rows into a Table variable based on a decision as to does the production part make 1 or 2 items ( The Raw data does not allow for this it comes from a look up in my database)

I can retrieve all the source data i need easily but when i come to insert it into the table variable i need to insert 1 record if its a single part or 2 records if its a twin part. I know could use a cursor but im sure there has to be an easier way !

Below is the code i have at the moment

declare @startdate as datetime
declare @enddate as datetime
declare @Line as Integer
DECLARE @count INT

set @startdate = '2015-01-01'
set @enddate = '2015-01-31'

[Code] .....

View 1 Replies View Related

Excel Cell Data To SQLEXPRESS

Feb 22, 2008

Hello, I am haing a little trouble with send cell data from an Excel sheet to SQLEXPRESS and I'm sure that it is not that hard. Has anybody else come accross this. I have the code below, but it is not complete as I'm not sure what to do to complete it:


Private Sub cmdSend_Click()

Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset

Dim strConn As String

strConn = "PROVIDER=SQLOLEDB;"

strConn = strConn & "DATA SOURCE=(local)SQLEXPRESS;INITIAL CATALOG=test;"

strConn = strConn & " INTEGRATED SECURITY=sspi;"

cn.ConnectionString = strConn
cn.Open

Set rs = New Recordset

With rs
' Assign the Connection object.
.ActiveConnection = cn
' Extract the required records.
.Open "UPDATE tblData Set ID = ID, Name = Name"
' Copy the records into cell A1 on Sheet1.
Sheet1.Range("A2, B2").CopyFromRecordset rs

' Tidy up
.Close
End With

cn.Close

End Sub



I know that it is not correct, but I am trying to convert a recordset query from SQL to Excel to Update Sql from Excel.

The cells from A2 down have an ID and cells from B2 down have a name.

Thanks for your time

View 1 Replies View Related

How To Copy Data From Sqlexpress 2005 Database?

Jan 30, 2008

 Hello everyone. i am using vwd 2005 express edition along with sqlexpress 2005. if i need to use database in my project. i click on database explorer and  create a new table from the existing database. it is working very fine. But my problem is when ever i copy the project in my pen driveand try to use in another computer,  the database doesnot gets copied when i copy my project folder. well i also tried to copy the tables from the database explorer but it does not happen.i tried to locate where does the database get stored in my computer.but i cant find where it resides..and even if i find which file to copy?i think there is log file and database file in some cases. can some body clarify me this scenario here.just tell me where can i find my database i m using in my project,so that i can copy it .  and also whats the use of creating .mdf file in  the project.?is this the better way of using database rather than creating using database explorer?confused?? thanks.jack..  

View 10 Replies View Related

SQLEXPRESS 2005 To SQL 2000 Data Transfer?

May 28, 2008

Hi All! i have a database in SQLEXPRESS 2005 but i need to this Database in SQL 2000...there is any way to move data from sqlexpress 2005 to sql 2000.... please help me..... 

View 4 Replies View Related

SQL Server 2005 Developer In My Computer, But ASP.NET Tab Configuration Was Data Source=.SQLEXPRESS?

Oct 12, 2006

Hello allMy computer was installed with SQL Server 2005 Developer version, however, I checked the Default Web Site in Internet Information Service console and saw that the ASP.NET configuration was not correct as below."data source=.SQLEXPRESS;Integrated Security=SSPI; AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"I have a question that can I replace the string, “.SQLEXPRESS”, with my server name and my SQL Server 2005 Developer named instance as below“DEVSERSQL2005Dev”?Thanks in advance for your help.

View 3 Replies View Related

Translation Of StrConnectie = Provider=SQLOLEDB; && _ Data Source=(local)SQLEXPRESS; &&

Jul 3, 2007

Hello,I'm struggling a giant fight with my webprovider (ASP.net 2.0) in the following case:I'm using the default connectionstring which automatic is provided when I create an ASP.net webstarterskit. This connectionstring is working fine when i deployed that kit to a W2003 server testenvironment and is also running on my laptop. But when I tried to deploy the website to my (new) hostingserver, also a W2003 server, I landed in ERROR-land. The last error I received was:Cannot open database "Club" requested by the login. The login failed.>
Login failed for user 'NT AUTHORITYNETWORK SERVICE'.NB: I gave that user the right privileges and roles.  My provider is not willing in sending me an example of a good working connectionstring and is directing me to their FAQ-site in which the right connectionstring is mentioned. That string looks like this (for a MS SQL database):strConnectie = "Provider=SQLOLEDB;" & _ "Data Source=(local)SQLEXPRESS;"
& _ "Initial Catalog=[GEBRUIKERSNAAM];" & _ "User Id=[GEBRUIKERSNAAM];" & _ "Password=[WACHTWOORD]"My connectionstring in web.config looks like this:<connectionStrings><clear/><add name="ClubSiteDB"
connectionString="Data
Source=.SQLExpress;Integrated Security=true;AttachDBFileName=|DataDirectory|Club.mdf;User
Instance=True" providerName="System.Data.SqlClient"/><remove
name="LocalSqlServer"/><add name="LocalSqlServer"
connectionString="Data Source=.SQLEXPRESS;Integrated Security=True;User 
Instance=True;AttachDBFilename=|DataDirectory|aspnetdb.mdf"
/></connectionStrings>Is there anybody in this forum that can help me out and explain to me how to use the string, as provided by the host, in the default connectionstring i use in web.config ??Any help is welcome and appreciated.NB: I'm using VWD 2005 Express Edition and SQL Server Management Studio ExpressHarry  Elzinga  

View 6 Replies View Related

Convert A SQLExpress File Based DB Project To SQLExpress Server DB Project

Jul 1, 2006

Hi All,I've been struggling with this for hours...Could someone please advise me on how to convert my current File based SQL Server Express website to a Server based SQL Express one.Particularly interested in what I need to do in the SQL Express management tool, changes I need to make the projecvt itself and changes needed to get IIS to understand things have been changed.Thanks,Martin.

View 1 Replies View Related

Cannot INSERT Data To 3 Tables Linked With Relationship (INSERT Statement Conflicted With The FOREIGN KEY Constraint Error)

Apr 9, 2007

Hello
 I have a problem with setting relations properly when inserting data using adonet. Already have searched for a solutions, still not finding a mistake...
Here's the sql management studio diagram :

 and here goes the  code1 DataSet ds = new DataSet();
2
3 SqlDataAdapter myCommand1 = new SqlDataAdapter("select * from SurveyTemplate", myConnection);
4 SqlCommandBuilder cb = new SqlCommandBuilder(myCommand1);
5 myCommand1.FillSchema(ds, SchemaType.Source);
6 DataTable pTable = ds.Tables["Table"];
7 pTable.TableName = "SurveyTemplate";
8 myCommand1.InsertCommand = cb.GetInsertCommand();
9 myCommand1.InsertCommand.Connection = myConnection;
10
11 SqlDataAdapter myCommand2 = new SqlDataAdapter("select * from Question", myConnection);
12 cb = new SqlCommandBuilder(myCommand2);
13 myCommand2.FillSchema(ds, SchemaType.Source);
14 pTable = ds.Tables["Table"];
15 pTable.TableName = "Question";
16 myCommand2.InsertCommand = cb.GetInsertCommand();
17 myCommand2.InsertCommand.Connection = myConnection;
18
19 SqlDataAdapter myCommand3 = new SqlDataAdapter("select * from Possible_Answer", myConnection);
20 cb = new SqlCommandBuilder(myCommand3);
21 myCommand3.FillSchema(ds, SchemaType.Source);
22 pTable = ds.Tables["Table"];
23 pTable.TableName = "Possible_Answer";
24 myCommand3.InsertCommand = cb.GetInsertCommand();
25 myCommand3.InsertCommand.Connection = myConnection;
26
27 ds.Relations.Add(new DataRelation("FK_Question_SurveyTemplate", ds.Tables["SurveyTemplate"].Columns["id"], ds.Tables["Question"].Columns["surveyTemplateID"]));
28 ds.Relations.Add(new DataRelation("FK_Possible_Answer_Question", ds.Tables["Question"].Columns["id"], ds.Tables["Possible_Answer"].Columns["questionID"]));
29
30 DataRow dr = ds.Tables["SurveyTemplate"].NewRow();
31 dr["name"] = o[0];
32 dr["description"] = o[1];
33 dr["active"] = 1;
34 ds.Tables["SurveyTemplate"].Rows.Add(dr);
35
36 DataRow dr1 = ds.Tables["Question"].NewRow();
37 dr1["questionIndex"] = 1;
38 dr1["questionContent"] = "q1";
39 dr1.SetParentRow(dr);
40 ds.Tables["Question"].Rows.Add(dr1);
41
42 DataRow dr2 = ds.Tables["Possible_Answer"].NewRow();
43 dr2["answerIndex"] = 1;
44 dr2["answerContent"] = "a11";
45 dr2.SetParentRow(dr1);
46 ds.Tables["Possible_Answer"].Rows.Add(dr2);
47
48 dr1 = ds.Tables["Question"].NewRow();
49 dr1["questionIndex"] = 2;
50 dr1["questionContent"] = "q2";
51 dr1.SetParentRow(dr);
52 ds.Tables["Question"].Rows.Add(dr1);
53
54 dr2 = ds.Tables["Possible_Answer"].NewRow();
55 dr2["answerIndex"] = 1;
56 dr2["answerContent"] = "a21";
57 dr2.SetParentRow(dr1);
58 ds.Tables["Possible_Answer"].Rows.Add(dr2);
59
60 dr2 = ds.Tables["Possible_Answer"].NewRow();
61 dr2["answerIndex"] = 2;
62 dr2["answerContent"] = "a22";
63 dr2.SetParentRow(dr1);
64 ds.Tables["Possible_Answer"].Rows.Add(dr2);
65
66 myCommand1.Update(ds,"SurveyTemplate");
67 myCommand2.Update(ds, "Question");
68 myCommand3.Update(ds, "Possible_Answer");
69 ds.AcceptChanges();
70

and that causes (at line 67):"The INSERT statement conflicted with the FOREIGN KEY constraint
"FK_Question_SurveyTemplate". The conflict occurred in database
"ankietyzacja", table "dbo.SurveyTemplate", column
'id'.
The statement has been terminated.
at System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable)
at AnkietyzacjaWebService.Service1.createSurveyTemplate(Object[] o) in J:\PL\PAI\AnkietyzacjaWebService\AnkietyzacjaWebServicece\Service1.asmx.cs:line 397"


Could You please tell me what am I missing here ?
Thanks a lot.
 

View 5 Replies View Related

Can't Insert New Data To Sql Using Sqldatasource.insert, Web Forms And A Master Page

Sep 11, 2006

Hello, I'm new to the forum and new to SQL, ASP.NET, etc.  I am creating an intranet site for my company in VS 2005 and have run into a very annoying problem that I can't seem to solve.  I have tried Googling it and came up empty.  I have a database in SQL Express 2005 and my website will be accessing several tables within the database.  I can retrieve info just fine and I can update, delete, etc just fine using gridview or other prebuilt tools, but when I add a few text boxes and wire a button to the SqlDataSource.Insert() command, I get a new record that is full of null values except for the identity key I have set.  The kicker is that I am also using a master page and when I duplicate the web page without the master page link, everything works just fine.  The following snippets show what I'm doing:<InsertParameters><asp:FormParameter Name="Name" Type="String" FormField="txtName" /><asp:FormParameter Name="Location" Type="String" FormField="ddlLocation" /><asp:FormParameter Name="Issue" Type="String" FormField="txtProblem" /></InsertParameters>Of course I match the formfields to the text boxes, create an onclick event for my button, the sqldatasource is configured correctly, it just doesn't work with the master page no matter what I do. Any help would be appreciated. Thanks

View 3 Replies View Related

Insert Command Fails When I Want To Insert Records In Data Table

Apr 20, 2008

On my site users can register using ASP Membership Create user Wizard control.
I am also using the wizard control to design a simple question and answer  form that logged in users have access to.
it has 2 questions including a text box for Q1 and  dropdown list for Q2.
I have a table in my database called "Players" which has 3 Columns
UserId Primary Key of type Unique Identifyer
PlayerName Type String
PlayerGenre Type Sting
 
On completing the wizard and clicking the finish button, I want the data to be inserted into the SQl express Players table.
I am having problems getting this to work and keep getting exceptions.
 Be very helpful if somebody could check the code and advise where the problem is??
 
 
<asp:Wizard ID="Wizard1" runat="server" BackColor="#F7F6F3"
BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px"
DisplaySideBar="False" Font-Names="Verdana" Font-Size="0.8em" Height="354px"
onfinishbuttonclick="Wizard1_FinishButtonClick" Width="631px">
<SideBarTemplate>
<asp:DataList ID="SideBarList" runat="server">
<ItemTemplate>
<asp:LinkButton ID="SideBarButton" runat="server" BorderWidth="0px"
Font-Names="Verdana" ForeColor="White"></asp:LinkButton>
</ItemTemplate>
<SelectedItemStyle Font-Bold="True" />
</asp:DataList>
</SideBarTemplate>
<StepStyle BackColor="#669999" BorderWidth="0px" ForeColor="#5D7B9D" />
<NavigationStyle VerticalAlign="Top" />
<WizardSteps>
<asp:WizardStep runat="server">
<table class="style1">
<tr>
<td class="style4">
A<span class="style6">Player Name</span></td>
<td class="style3">
<asp:TextBox ID="PlayerName" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="PlayerName" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style5">
 
<td class="style3">
<asp:DropDownList ID="PlayerGenre" runat="server" Width="128px">
<asp:ListItem Value="-1">Select Genre</asp:ListItem>
<asp:ListItem>Male</asp:ListItem>
<asp:ListItem>Female</asp:ListItem>
</asp:DropDownList>
</td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="PlayerGenre" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
</td>
 
</tr>
</table>
  Sql Data Source
<asp:SqlDataSource ID="InsertArtist1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" InsertCommand="INSERT INTO [Playerst] ([UserId], [PlayerName], [PlayerGenre]) VALUES (@UserId, @PlayerName, @PlayerGenre)"
 
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>">
<InsertParameters>
<asp:Parameter Name="UserId" Type="Object" />
<asp:Parameter Name="PlayerName" Type="String" />
<asp:Parameter Name="PlayerGenre" Type="String" />
</InsertParameters>
 
 
</asp:SqlDataSource>
</asp:WizardStep>
 
 Event Handler
 
To match the answers to the user I get the UserId and insert this into the database to.protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e)
{
 SqlDataSource DataSource = (SqlDataSource)Wizard1.FindControl("InsertArtist1");
MembershipUser myUser = Membership.GetUser(this.User.Identity.Name);
Guid UserId = (Guid)myUser.ProviderUserKey;String Gender = ((DropDownList)Wizard1.FindControl("PlayerGenre")).SelectedValue;
DataSource.InsertParameters.Add("UserId", UserId.ToString());DataSource.InsertParameters.Add("PlayerGenre", Gender.ToString());
DataSource.Insert();
 
}
 

View 1 Replies View Related

How To Insert Data From A File Into Table Having Two Columns-BULK INSERT

Oct 12, 2007



Hi,
i have a file which consists data as below,

3
123||
456||
789||

Iam reading file using bulk insert and iam inserting these phone numbers into table having one column as below.


BULK INSERT TABLE_NAME FROM 'FILE_PATH'
WITH (KEEPNULLS,FIRSTROW=2,ROWTERMINATOR = '||')

but i want to insert the data into table having two columns. if iam trying to insert the data into table having two columns its not inserting.

can anyone help me how to do this?

Thanks,
-Badri

View 5 Replies View Related

How Do I Call A Stored Procedure To Insert Data In SQL Server In SSIS Data Flow Task

Jan 29, 2008



I need to call a stored procedure to insert data into a table in SQL Server from SSIS data flow task.
I am currently trying to use OLe Db Destination, but I am not sure how to map inputs to OLE DB Destination to my stored procedure insert.
Thanks

View 6 Replies View Related

SQL Server 2014 :: How To Insert CSV Data Into DB Where Some Data Don't Have Double Quotes

Aug 11, 2015

Example of data in CSV are as follows:

"XXX","0001",-990039739 ,0 ,0 ,0 ,0 ,0 ,0
"ABC"," ",-3422054702 ,0 ,481385 ,0 ,0 ,0 ,0
"JJZ","0001",0 ,0 ,0 ,0 ,0 ,0 ,0Here's my format:
12.0
10
1 SQLCHAR 0 0 """ 0 "" ""
2 SQLCHAR 0 5 "","" 1 OKCCY SQL_Latin1_General_CP1_CI_AS

[Code] ....

View 5 Replies View Related

Insert Data To A Table Where Select Data From Another SERVER

Oct 8, 2007

I had a function like below :Public Sub Getdata2(ByVal query, ByVal db, ByVal name)
Dim selectSQL As StringDim con As SqlConnection
Dim cmd As SqlCommand
Dim reader As SqlDataReader
Trycon = New SqlConnection("User ID=xxx;password=xxx;persist security info=True;Initial Catalog=database1;Data Source=xxx.xxx.xxx.xxx.xxx,xxxxx;")
Dim username As String
username = Request.QueryString("username")
selectSQL = "SET DATEFORMAT DMY;Insert into table1(hse_num, st_name, proj_name, unit_num, postal, n_postal, flr_area, flr_sf, flr_rate, flr_ra_sf, land_area, land_sf, land_rate, lnd_ra_sf, prop_code, cont_date, title, sisv_ref, r_date, rec_num, source, username, DGP, Remarks, Sub_Code, caveat, consider, age) select hse_num, st_name, proj_name, unit_num, postal, n_postal, flr_area, flr_sf, flr_rate, flr_ra_sf, land_area, land_sf, land_rate, lnd_ra_sf, prop_code, cont_date, title, sisv_ref, r_date, rec_num, source, '" & username & "', DGP, Remarks, Sub_Code, caveat, consider, age from [yyy.yyy.yyy.yyy,yyyy].database2.dbo.table2 where " & querycmd = New SqlCommand(selectSQL, con)
con.Open()
reader = cmd.ExecuteReader()
lbl.Text = selectSQLCatch ex As Exception
lbl.Text = ex.Message
Finally
If (Not con Is Nothing) Then
con.Close()
con.Dispose()
End If
End Try
End Sub
'------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
May i know that how do i retrieve data from  [yyy.yyy.yyy.yyy,yyyy].database2.dbo.table2 due to diffrent server, diffrent UID and Password
 

View 1 Replies View Related

Why Won't This Data Insert?

Feb 15, 2008

I am severly sleep deprived from this issue and this deliverable deadline is tomorrow, so anyone who can help me solve it will earn my deepest gratitude. 
I have a form that inserts/updates to one table (table A), then inserts a record into another table (table B) (based on the user_id generated from the insert on the first table).
All of my queries/inserts work fine, UNTIL I get to my last insert (the one for table B).  I don't get any compilation errors, and the insert/update to table A works just fine.  But table B continues to be empty.
 I have tried it by calling a stored procedure that does the update, as well as just writing the insert statement right into the code, and neither works.
 If I execute the stored procedure directly on the db server and manually pass it the parameters, the insert works.At first I thought that the problem must be in the placement of my code on the page -- that perhaps that section wasn't even executing.  But I know that it is because I can output my debugging that is contained right at the beginning of this section of code: 
// Insert the print material requests into the INFO_REQUEST table
//Response.Write("CB1: " + print_materials);
//Response.Write("CB2: " + pricing);
//Response.Write("CB3: " + newsletter);SqlCommand myCommand2;
 myCommand2 = new SqlCommand("info_request_insert", localConnection);
myCommand2.CommandType = CommandType.StoredProcedure;myCommand2.Parameters.Add(new SqlParameter("@user_id", user_id));
myCommand2.Parameters.Add(new SqlParameter("@current_customer", "N"));myCommand2.Parameters.Add(new SqlParameter("@print_product", "na"));
myCommand2.Parameters.Add(new SqlParameter("@print_materials", print_materials));myCommand2.Parameters.Add(new SqlParameter("@business_line", "na"));
myCommand2.Parameters.Add(new SqlParameter("@pricing", pricing));myCommand2.Parameters.Add(new SqlParameter("@demo", "na"));
myCommand2.Parameters.Add(new SqlParameter("@training", "na"));myCommand2.Parameters.Add(new SqlParameter("@ask_expert", "na"));
myCommand2.Parameters.Add(new SqlParameter("@recommend_friend_email", ""));myCommand2.Parameters.Add(new SqlParameter("@user_from", newsletter));
myCommand2.Parameters.Add(new SqlParameter("@cad_programs", "na"));myCommand2.Parameters.Add(new SqlParameter("@solver_programs", "na"));
myCommand2.Parameters.Add(new SqlParameter("@desktop_platform", "na"));myCommand2.Parameters.Add(new SqlParameter("@current_customer", "na"));
myCommand2.Parameters.Add(new SqlParameter("@submit_date", DateTime.Now));myCommand2.Parameters.Add(new SqlParameter("@comments", "na"));
try
{
myCommand2.Connection.Open();
myCommand2.ExecuteNonQuery();
myCommand2.Connection.Close();
}catch (Exception ex)
{Trace.Write("00-msg", ex.Message);if (myCommand2.Connection.State == ConnectionState.Open)
{
myCommand2.Connection.Close();
}
}
 

View 6 Replies View Related

Insert Data To Sql Db

Apr 23, 2008

 After reading through the forums ... Getting confused as I am new to the asp thing ...I want to type data into a text box, click a button (have this part down)I want the data from the text box to be inserted into a table in a sql db. Whats the best way to do this, tutorial or examples as well? 

View 5 Replies View Related

Help Insert XML Data

Jan 4, 2008

Dear All,

I'm new handle XML file, I have a question how to create procedure insert XML data into SQL table, let say we have table with schema like this
create table testXML
(col1 real,
col2 real,
col3 real)

I want to insert XML data
<firstdata>
<data>499,498.99,1.25</data>
<data>500.01,500,1.9</data>
<data>501.03,501.02,2.92</data>
</firstdata>

the result we need is
col1 col2 col3
499 498.99 1.25
500.01 500 1.9
501.03 501.02 2.92

thank's before

Regards

View 1 Replies View Related

Insert Data?

Mar 19, 2007

I would like to know how to import historical data with different tagname into same table with new tagname?....ie

Table Data:

old tagname = PS001_Pump2.RT_Daily

new tagname =PS001_Pump2.Daily_Runtime





DateTime TagName Value

2007-12-03 PS001_Pump2.Daily_Runtime 1.45

2007-12-04 PS001_Pump2.Daily_Runtime 2.07

2007-12-07 PS001_Pump2.RT_Daily 3.98



this is what i am looking to do:

DateTime TagName Value

2007-12-03 PS001_Pump2.Daily_Runtime 1.45

2007-12-04 PS001_Pump2.Daily_Runtime 2.07

2007-12-07 PS001_Pump2.Daily_Runtime 3.98



historical data is in same table as new tags, but i need to delete the old tags because of license constraint, but i need to move the old data into the new tags.

I am currently running sql2000.











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

Insert Data Into Sql Problem

Mar 12, 2008

Hi people,
I've got a textbox and a button, I want to be able to put some text in the textbox and once i click on the button it will send it into the database. How would i go about doing this?
Please help

View 6 Replies View Related

How To Insert Data In To Two Tables?

May 12, 2005

hi,
i have got a problem, iam creating an asp.net application, but i pretend to insert data in two different tables, but i have no ideia how to do this.Can you help to solve this problem? please..........

View 3 Replies View Related

How To Insert Data In To Two Tables?

May 12, 2005

hi,
iam creating an asp.net application the database is created on the SQLSERVER, but i have a problem, i pretend to insert data in to 2 tables and i have no ideia how to do this. Can you help me to solve this problem? Please.....

View 1 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 CSV File Data To MS Sql

Sep 8, 2005

How to upload file data into ms sql server?

thanks

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







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