Error While Inserting Time
Feb 10, 2007
hi i am trying to insert time in my column which is in my table.my table has one column named as "intime" which has datatype as datetime.
i am doing thuis in vb.net.
i used this code in vb.net to get time:
dim dat as datetime=datetime.now.tostring("hh:mm:ss tt")
and i got time.but i am having this spc for insert:
create procedure sptimeinsert(@time datetime)
as
insert into time values:
An unhandled exception of type 'System.Data.SqlTypes.SqlTypeException' occurred in system.data.dll
Additional information: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM
please any one help to solve this error.
View 5 Replies
ADVERTISEMENT
Dec 31, 2007
Hi
My time dimension has date mm/dd/yy 00:00:00
where as the source has mm/dd/yy and some time not 00:00:00
I am sure the iserts in fact table are failing.
I do not want the time part to come anywhere in data mart.
what should i do in SSIS.
View 1 Replies
View Related
Aug 11, 2003
I am wanting to populate a datetime field with data retrieved from 4 dropdowns month, day, year and hour 08:00 - 18:00.
I am having trouble joining them together in a format that the sql server recognises.
View 3 Replies
View Related
Mar 1, 2007
In the code below why does it not enter 10:00 AM but instead it enters: 1900-01-01 10:00:00.000 ?
Create Table MyDateTest
(
DateColumn datetime
)
insert into MyDateTest values ('10:00 AM')
select DateColumn from MyDateTest
--PhB
View 3 Replies
View Related
Mar 14, 2008
I need to insert rows into a table which contains a smallint field
for time. The times are stored in that colum as integers (898,
11345, 1259, etc.) How can I enter a time like 9:15 AM into this field? I know how to display integer data in hh:mm format but I'm stumped on how I can do the reverse.
Thanks for any help offered.
View 12 Replies
View Related
Mar 21, 2008
Hi,I've a strange problem with a INSERT query. It's taking a long time toexecute. The format is like this :INSERT INTO table1SELECT ..FROM table2Executing the SELECT .. FROM table2 is taking 30 seconds. The resultis nothing: no records are selected.When i include the INSERT part it will take 12 hours to completeINSERT INTO table1SELECT ..FROM table2There's is an index on the table and when i delete it, it gives stillthe problem.Keh?Greetz,Hennie
View 1 Replies
View Related
Nov 12, 2007
I have asp.net 1.1 web form and it inserts date and time in SQL database, but it insert only date not time , It insert date time in following format
2002-01-22 00:00:00.000
some one tell me why it is not inserting time or why it is inserting time as 00:00:00:000.
I want to my time to look like 14:42:51:153. (format)
How can I change my time format
give me asp.net codes for time formating or what do I need to do to resolve the problem,
thank you
maxmax
View 1 Replies
View Related
Mar 30, 2007
I need an SQL string that inserts the current date into a database.
So far I have tried:
SQL = "INSERT INTO X (START_DATE) VALUES ('" & Date.Now & "')"
mycomm = New SqlCommand(sql, myconn)
mycomm.ExecuteNonQuery()
However, there is a problem with the SQL command. The problem is related to the date. Is there a way of programatically inserting the current date/time into the SQL database? Language used is VB.
View 1 Replies
View Related
Apr 19, 2007
Hi folks,
After getting a form view inserting some values into a mdb file, it inserts the same values a second time on page reload.
How may I cure this? Any suggestions?
VB Code is below.
many thanks in advance
Rosi
1 <%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="km_Eingabe.aspx.vb" Inherits="km_Eingabe" title="km-Eingabe" %>
2 <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
3 <table style="width: 750px; height: 210px">
4 <tr>
5 <td style="height: 38px">
6 </td>
7 <td style="height: 38px">
8 <asp:DropDownList ID="dropdownlist1" runat="server" AutoPostBack="True" DataSourceID="AccessDataSource2"
9 DataTextField="polKennz" DataValueField="polKennz">
10 </asp:DropDownList>
11 </td>
12 <td style="height: 38px">
13 </td>
14 </tr>
15 <tr>
16 <td style="height: 235px">
17 </td>
18 <td style="height: 235px" valign="top">
19
20 <asp:FormView ID="FormView1" runat="server" CellPadding="4" DataSourceID="SqlDataSource1"
21 ForeColor="#333333">
22 <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
23 <EditRowStyle BackColor="#999999" />
24 <EditItemTemplate>
25
26 </EditItemTemplate>
27 <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
28 <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
29 <EmptyDataTemplate>
30 keine Daten vorhanden
31 <br />
32 <asp:LinkButton ID="NewButton" runat="server" CommandName="New" Text="Neuer Eintrag"></asp:LinkButton>
33 </EmptyDataTemplate>
34 <InsertItemTemplate>
35 Datum:
36 <asp:TextBox ID="DatumTextBox" runat="server" Text='<%# Bind("Datum", "{0:d}") %>'>
37 </asp:TextBox>
38 <br />
39 Fahrer:
40 <asp:TextBox ID="FahrerTextBox" runat="server" Text='<%# Bind("Fahrer") %>'>
41 </asp:TextBox>
42 <br />
43 polKennz:
44 <asp:TextBox ID="polKennzTextBox" runat="server" Text='<%# Bind("polKennz") %>'>
45 </asp:TextBox>
46 <br />
47 neuer_Eintrag:
48 <asp:TextBox ID="neuer_EintragTextBox" runat="server" Text='<%# Bind("neu") %>'></asp:TextBox>
49 <br />
50 aktuell:
51 <asp:TextBox ID="aktuellTextBox" runat="server" Text='<%# Bind("aktuell") %>'></asp:TextBox> <br />
52 <br />
53 <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
54 Text="Einfügen" OnClick="InsertButton_Click">
55 </asp:LinkButton>
56 <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
57 Text="Abbrechen">
58 </asp:LinkButton>
59 </InsertItemTemplate>
60 <ItemTemplate>
61 Datum:
62 <asp:Label ID="DatumLabel" runat="server" Text='<%# Bind("Datum") %>'></asp:Label><br />
63 Fahrer:
64 <asp:Label ID="FahrerLabel" runat="server" Text='<%# Bind("Fahrer") %>'></asp:Label><br />
65 polKennz:
66 <asp:Label ID="polKennzLabel" runat="server" Text='<%# Bind("polKennz") %>'></asp:Label><br />
67 neu:
68 <asp:Label ID="neuLabel" runat="server" Text='<%# Bind("neu") %>'></asp:Label><br />
69 lfdNr:
70 <asp:Label ID="lfdNrLabel" runat="server" Text='<%# Eval("lfdNr") %>'></asp:Label><br />
71 aktuell:
72 <asp:Label ID="aktuellLabel" runat="server" Text='<%# Bind("aktuell") %>'></asp:Label><br />
73 Dienststelle:
74 <asp:Label ID="DienststelleLabel" runat="server" Text='<%# Bind("Dienststelle") %>'></asp:Label><br />
75 <asp:LinkButton ID="NewButton" runat="server" CommandName="New" Text="Neuer Eintrag"></asp:LinkButton>
76 </ItemTemplate>
77 <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
78 </asp:FormView>
79 </td>
80 <td style="height: 235px">
81 </td>
82 </tr>
83 <tr>
84 <td>
85 </td>
86 <td>
87 </td>
88 <td>
89 </td>
90 </tr>
91 </table>
92 <asp:AccessDataSource ID="AccessDataSource2" runat="server" DataFile="~/App_Data/KfzDaten_Ansicht.mdb"
93 SelectCommand="SELECT DISTINCT [polKennz] FROM [qry_KennzeichenAlle_ohne_ausgesondert]">
94 </asp:AccessDataSource>
95 <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/KfzDaten_Ansicht.mdb"
96 SelectCommand="SELECT DISTINCT [Datum], [Nutzer], [Fahrer], [polKennz], [aktuell], [neu], [gefahren] FROM [qry_Fahrtenbuch_letzter_Eintrag_pro_Kfz] WHERE ([polKennz] = ?)">
97 <SelectParameters>
98 <asp:ControlParameter ControlID="DropDownList1" Name="polKennz" PropertyName="SelectedValue"
99 Type="String" />
100 </SelectParameters>
101 </asp:AccessDataSource>
102 <asp:SqlDataSource ID="SqlDataSource1" DataSourceMode="DataSet" ConflictDetection="CompareAllValues" InsertCommandType="Text" runat="server" ConnectionString="<%$ ConnectionStrings:KfzDaten_Ansicht_mdbConnectionString %>" ProviderName="<%$ ConnectionStrings:KfzDaten_Ansicht_mdbConnectionString.ProviderName %>"
103 InsertCommand= "INSERT INTO Tab_import_Fahrtenbuch([Datum], [Fahrer], [polKennz], [neu], [aktuell]) VALUES (@Datum, @Fahrer, @polKennz, @Eingabe_neu, @Eingabe_aktuell )" >
104 <SelectParameters>
105 <asp:ControlParameter ControlID="dropdownlist1" Name="newparameter" PropertyName="SelectedValue" />
106 </SelectParameters>
107 <InsertParameters>
108 <asp:FormParameter FormField="DatumTextBox" Name="Datum" Type="string" />
109 <asp:FormParameter FormField="FahrerTextBox" Name="Fahrer" Type="string" />
110 <asp:FormParameter FormField="polKennzTextBox" Name="polKennz" Type="string" />
111 <asp:FormParameter FormField="neuer_EintragTextBox" Name="neu" Type="Int32" ConvertEmptyStringToNull="false" />
112 <asp:FormParameter FormField="aktuellTextBox" Name="aktuell" Type="Int32" ConvertEmptyStringToNull="false" Direction="Input" />
113 </InsertParameters>
114 </asp:SqlDataSource>
115
116 </asp:Content>
117
118
View 5 Replies
View Related
Jan 11, 2007
hello,
I am trying to insert date and time into my table.
insert into <table_name> values('12/12/2006','12:23:04');
but it displays error at " ; "
can anyone help me to figure out the problem
Thanks a lot in advance.
Regards,
Sweety
View 3 Replies
View Related
Feb 25, 2006
hey guys I got an error when trying to insert an SQL statement.
basically it when I try to insert into a unique ID column I think
error is:
Compiler Error Message: BC30516: Overload resolution failed because no accessible 'New' accepts this number of arguments.Source Error:
Line 51: objCmd = New SQLCommand(strSQL1, SqlConn)
Line 52:
Line 53: objCmd.Parameters.Add(New SqlParameter("@CustomerID"))
Line 54: objCmd.Parameters("@CustomerID").Value = UserID
Line 55: objCmd.Parameters.Add(New SqlParameter("@CompanyID", _Source File: C:Prototypeofficial1html icketsystem.aspx Line: 53
Dim strConnection as string = ConfigurationManager.ConnectionStrings("GeolinkSupportdb").connectionstring
Dim sqlConn = New SqlConnection(strConnection)
dim mu = Membership.GetUser()
dim UserID = mu.ProviderUserKey.ToString()
Sub Page_Load(sender as Object, e as EventArgs)
If Not IsPostBack() then
'1. Create a connection
Dim sqlConn = New SqlConnection(strConnection)
'2. Create the command object, passing in the SQL string
Const strSQL as String = "SELECT IssueID, IssueName FROM Support_Issue;"
sqlConn.Open()
Dim myCommand as New SqlCommand(strSQL, sqlConn)
'3. Create the DataReader
Dim objDR as SqlDataReader
objDR = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
'Databind the DataReader to the listbox Web control
TicketIssue.DataSource = objDR
TicketIssue.DataTextField = "IssueName"
TicketIssue.DataValueField = "IssueID"
TicketIssue.DataBind()
'Add a new listitem to the beginning of the listitemcollection
TicketIssue.Items.Insert(0, new ListItem("-- Choose an Issue --"))
objDR.close()
sqlConn.Close()
'assign fullname from profile and company ID to the text fields.
FullName.Text = profile.firstName & " " & profile.lastName
Company.Text = profile.CompanyID
end if
End Sub
Sub Submit(sender as Object, e as EventArgs)
Dim rightNow as DateTime = DateTime.Now
Dim strSQL1 = "insert into Support_Ticket (CustomerID, CompanyID, Subject, Problem, Open_Date, IsClosed) Values (@CustomerID, @CompanyID, @Subject, @Problem, @OpenDate, @IsClosed);"
Dim objCmd As SqlCommand
objCmd = New SQLCommand(strSQL1, SqlConn)
objCmd.Parameters.Add(New SqlParameter("@CustomerID", _
SqlDbType.uniqueidentifier))
objCmd.Parameters("@CustomerID").Value = UserID
objCmd.Parameters.Add(New SqlParameter("@CompanyID", _
SqlDbType.uniqueidentifier))
objCmd.Parameters("@CompanyID").Value = profile.CompanyID
objCmd.Parameters.Add(New SqlParameter("@Subject", _
SqlDbType.varchar, 50))
objCmd.Parameters("@Subject").Value = Subject.Text
objCmd.Parameters.Add(New SqlParameter("@Problem", _
SqlDbType.ntext))
objCmd.Parameters("@Problem").Value = TicketInfo.Value
objCmd.Parameters.Add(New SqlParameter("@Open_Date", _
SqlDbType.DateTime))
objCmd.Parameters("@Open_Date").Value = rightNow.ToString("dd/MM/yyyy , HH:mm:ss")
objCmd.Connection.Open()
objCmd.Parameters.Add(New SqlParameter("@IsClosed", _
SqlDbType.bit))
objCmd.Parameters("@IsClosed").Value = 0
' Test whether the new row can be added and display the
' appropriate message box to the user.
Try
Catch ex As SqlException
objCmd.ExecuteNonQuery()
Message.InnerHtml = "<b>Record Added</b> to Database<br>"
If ex.Number = 2627 Then
Message.InnerHtml = "ERROR: A record already exists with " _
& "the same primary key"
Else
Message.InnerHtml = "ERROR: Could not add record, please " _
& "ensure the fields are correctly filled out"
Message.Style("color") = "red"
End If
End Try
objCmd.Connection.Close()
end sub
the database looks like this
TicketID uniqueidentifier CustomerID uniqueidentifier Subject varchar(50) Problem ntext Open_Date datetime IsClosed bit Closed_Date datetime DeptID uniqueidentifier CompanyID varchar(50)
View 2 Replies
View Related
Apr 20, 2004
Hey folks,
I am trying to updat a table by inserting values from another table into the parent table. The SQL being used is:
"insert into "LogSchema"."_rt1182" select * from "LogSchema"."_rt557" where recordID not in (select * from "LogSchema"."_rt1182") ORDER BY TIMESTAMP"
I have used the above statement and was successful, but with these two particluar tables I am getting an error message" Wrong number of values to INSERT"
Please lemme know, what this means and how to correct this problem!
TIA
View 3 Replies
View Related
Apr 25, 2006
Msg 515, Level 16, State 2, Procedure aspnet_Roles_CreateRole, Line 37
Cannot insert the value NULL into column 'RoleId', table 'PORTAL.MDF.dbo.aspnet_Roles'; column does not allow nulls. INSERT fails.
The statement has been terminated.
this MS sql server 2005 using the aspnetdb.mdf.
The RoleID is an primary key and supposed to be autopopulating itself everytime there is an new insertion correct? so what is the problem?
View 3 Replies
View Related
May 8, 2000
i get error 605 on several occassions... namely when i am doing a bcp into the database OR when a user is trying to update a record. it seems very sparodic otherwise, but it always happens during the bcp insert. if anyone has any ideas or suggestions on how to correct this issue, it would be greatly appreciated. need additional info?
View 5 Replies
View Related
Mar 25, 1999
We are running a application that uses SQL. No users use this database but the application. We have been getting an error stating that there was an error inserting into one of my tables. We have increased the LE Threshold to 10000 and have also increased my locks to 200000 but it still doesn't get rid of the problem. Any ideas as to why. I can't imagine that this application will hold that many locks but then again I'm not the developer. Any suggestions will help.
Ben
View 2 Replies
View Related
Mar 29, 2007
Hi all,
I made a C# function to insert new row to MS SQL Server 2005. However, I kept getting this error when I executed it:
Code:
Line 1: Incorrect syntax near '0'.
Unclosed quotation mark before the character string '','{ 0 }','Sun, Mar 25, 2007 04:33:00 PM')'.
here is the sql insert statement
Code:
insert into Temip_tmp_3(Managed_object, Alarm_type, Perceived_Severity, Probable_Cause, Domain, Additional_Text, Specific_Problems, Original_Event_Time ) values ('','EquipmentAlarm','Major','EquipmentMalfunction','Domain tsel_ns:.dom.radio_ericsson','"EXTERNAL ALARM RECEIVER FAULT *** ALARM 121 A2/IO_DEV BTAK1 042/0700H U 070325 1633 EXTERNAL ALARM RECEIVER FAULT AP APNAME NODE NODENAME 1 AP_BTAK1_C A AP_BTAK1_A APNODE FCODE B FAULT CODE 23 **SpecificProblem:121 , AdditionalInfo:@@"','{ 0 }','Sun, Mar 25, 2007 04:33:00 PM')
I believe there is not a single quotation mark unclosed in my query. And, what's so funny is when I tried to execute the query on SQL Server Enterprise Manager, it worked.
I don't know, maybe I missed something.
Can you guys please help me figure this out?
Thank you very much in advance.
Shinta
View 1 Replies
View Related
May 14, 2014
i have created a multiple database for other reasons i have to change all into one data base for that i have done graphically by using generate scripts by using this all data base tables, & store procedures all are created . by using webform i just inserting data to database. but here i am getting an error to me that the error has "Cannot insert the values NULL Into column Tblename database.dbo.columnname does not allow nulls.insert fails the statement has been terminated."here the primary key has not working in runtime.
View 1 Replies
View Related
Oct 15, 2006
my requirment is insert TableName and JourneyDate and FlightNumber alongwith otherdata at RunTime but i get error, I tried it several times. Table Structure is: Create Table HA142
(
JourneyDate DateTime primary key,
FlightNo char(5)not null FOREIGN kEY REFERENCES FLIGHTS(FlightNo),
FirstClassSeatAvalable int,
BusinessClassSeatAvalable int,
EconomyClassSeatAvalable int,
FsWaitingAvalable int,
BsWaitingAvalable int,
EcWaitingAvalable int
) string flightno = drpFlightNo.SelectedItem.Text;
string JourneyDate = Session["JourneyDate"].ToString();
string newStrign = ",18,42,280,3,7,35)";
SqlConnection myConn = new SqlConnection("workstation id=JASIM;packet size=4096;user id=ASPNET;data source=JASIM;persist security info=False;initial catalog=Test");
SqlCommand populateFlightTable = new SqlCommand("INSERT INTO "+flightno+" VALUES("+JourneyDate+","+flightno+newStrign,myConn);
myConn.Open();
populateFlightTable.ExecuteNonQuery();
myConn.Close(); whenever compiler reached to populateFlightTable.ExecuteNonQuery(); I received error. i tried it to rectify several times but no result.plz hemp me...
View 3 Replies
View Related
Feb 21, 2007
I am trying to insert 1000000.00 into my sql table from a webpage. I as long as the amount is 999.99 or less it works fine, once higher then that amount it gives me an error.
Below is the code I am using to do the insert, it gets the error on the insert and the update both:
I am getting the error on the price inserting the FormatCurrency(txtprice.Text)
SelectStatement = "Insert crewchief (crewchief, price, car_num) Select '" & txtcrewchief.Text & "', " & FormatCurrency(txtprice.Text) & ", '" & txtcarnum.Text & "'"
Adapter.SelectCommand = New SqlClient.SqlCommand(SelectStatement, myConnection)
MyCommandBuilder = New SqlClient.SqlCommandBuilder(Adapter)
Adapter.Fill(MatcherDS, "temp")
Any ideas on why?
Thank you
View 2 Replies
View Related
Apr 12, 2007
Greetings,
When using Inserting event of SqlDataSource ASP.NET gives me an error when I reference InsertParameter by Name
An SqlParameter with ParameterName 'CreatedByEmployeeId' is not contained by this SqlParameterCollection.
However, when I reference parameter by index everything works.
Is this a bug or I'm doing something wrong?
Here's the code:
<asp:SqlDataSource ID="dsRole" runat="server" ConnectionString="<%$ ConnectionStrings:SecurityConnectionString %>" DeleteCommand="spDeleteRole" InsertCommand="spAddRole" SelectCommand="spGetRole" UpdateCommand="spUpdateRole" DeleteCommandType="StoredProcedure" InsertCommandType="StoredProcedure" SelectCommandType="StoredProcedure" UpdateCommandType="StoredProcedure">
<DeleteParameters>
<asp:Parameter Name="RoleId" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="RoleId" Type="Int32" />
<asp:Parameter Name="RoleName" Type="String" />
<asp:Parameter Name="RoleDescription" Type="String" />
<asp:Parameter Name="UpdatedByEmployeeId" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="RoleName" Type="String" />
<asp:Parameter Name="RoleDescription" Type="String" />
<asp:Parameter Name="CreatedByEmployeeId" Type="Int32" />
</InsertParameters>
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="RoleId" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
When using parameter name, I get an error:
Protected Sub dsRole_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles dsRole.Inserting
e.Command.Parameters("CreatedByEmployeeId").Value = Internal.Security.GetEmployeeIdFromCookie(Page.Request.Cookies)
End Sub
When using index instead of name, there's no problem:
Protected Sub dsRole_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles dsRole.Inserting
e.Command.Parameters(2).Value = Internal.Security.GetEmployeeIdFromCookie(Page.Request.Cookies)
End Sub
View 2 Replies
View Related
Jun 21, 2007
hi,
I am using asp.net web admin tool to create users and the other personal details of the user are stored in a table called "Users". So in my Users table I have a field called "Id" which is of datatype UniqueIdentifier. The UserId generated in the aspnet_Membership table is also stored in my "Users" table's Id field. The problem is that an error is thrown when executing the statement
System.Web.Security.Roles.AddUserToRole(name, Role). The parameters name and role are getting values correctly. But as soon as this is executed a sql exception is thrown saying that "The conflict of interleave for the equal operator cannot be solved to."
Am not able to solve this.Pls help me out.
Thanks in Advance.
View 3 Replies
View Related
May 9, 2008
I created my own table on the ASPNETDB.mdf file.
When i try to insert data on it, i get an exception:
System.Data.SqlClient.SqlException was unhandled by user code Message="String or binary data would be truncated.
The statement has been terminated." Source=".Net SqlClient Data Provider" ErrorCode=-2146232060 Class=16 LineNumber=1 Number=8152 Procedure="" Server="\\.\pipe\33189AFE-4730-4B\tsql\query"....
My C# code to insert:SqlConnection conexao =
new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString);
string query = "Insert Into NovasMaquinas " +"(NomeDaMaquina, FicheiroExecutavel, FicheiroXML, AdminQueSubmeteu, Autor, VmID)" +
"Values (@NomeDaMaquina, @FicheiroExecutavel, @FicheiroXML, @AdminQueSubmeteu, @Autor, @VmID)";SqlCommand cmd = new SqlCommand(query, conexao);
cmd.Parameters.AddWithValue("@NomeDaMaquina", textboxNomeVM.Text);cmd.Parameters.AddWithValue("@FicheiroExecutavel", path + fileUploadEXE.PostedFile.FileName);
cmd.Parameters.AddWithValue("@FicheiroXML", path + fileUploadEXE.PostedFile.FileName);cmd.Parameters.AddWithValue("@AdminQueSubmeteu", User.Identity.Name);
cmd.Parameters.AddWithValue("@Autor", textboxAutorVM.Text);cmd.Parameters.AddWithValue("@VmID", Guid.NewGuid().ToString());
conexao.Open();
//cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery(); //THAT IS THE LINE WHERE THE EXCEPTION IS THROWN
conexao.Close();
Any ideas wath i'm doing wrong?
View 2 Replies
View Related
Jul 11, 2006
I'm getting a syntax error in my insert data:
Error Executing Database Query.
Syntax error in INSERT INTO statement.
The error occurred in D:HostingkpstoolinsertPage.cfm: line 132
130 : datasource= "kpstool_accesscf_jobs">
131 : INSERT INTO Jobs (Position, Needs, Necessary)
132 : VALUES ('#form.Position#','#form.Needs#','#form.Necessary#')
133 : </cfquery>
134 : <cfoutput>
This is the code for the form that this code is referring to:
<form action="insertpage.cfm" method="post" name="Form" id="Form">
Position:
<input type="text" name="Position" size="25" maxlength="25">
<br>
<input type="hidden" name="Position_required" value="You must enter position">
<br>
Needs:
<input type="text" name="Needs" size="25" maxlength="25">
<br>
Necessary:
<input type="text" name="Necessary" size="25" maxlength="25">
<br>
</p>
<p>
<input type="submit" name="Submit" value="insert data">
<input type="Reset" name="submit" value="Clear form">
<br>
</p>
</form>
Any help would be great.
View 7 Replies
View Related
Feb 17, 2006
How do I go about inserting records on a table that has a PK/FK relationship with another table?? I get a foreign key error everytime I try :)
View 1 Replies
View Related
Oct 4, 2007
Hello.
I'm working with SQL Server 2005 Standard edition.
I have a Java program that loads PDF files into the database. I have a table called T08_entity which, among others, has two IMAGE columns. The first Image column is for the original PDF file. The second one is for the PDF file with modified permissions (printing, saving, etc). This is made using the i-text library.
The programs looks for the content of a disk folder, reads the contents of the folder, and inserts, one by one, the pdf files (besides other fields, like the name of the file, and ID, etc... but these are varchar or int fields. No problem with these.
When the folder has only small files (smaller that 7-8 mb), it loads them without any problem into the database. But when the folder has bigger files (>10mb, more or less...) I get an OUT OF MEMORY error.
I'm using the latest sqljdbc.jar driver (v1.2.2727). My server computer has only 1GB of RAM... but I've read that this latest driver can load big amounts of binary data using the connection property "responseBuffering=adaptive".
Here is a sample of my code (at least the most relevant lines):
This is my connection code:
public String getConnectionUrl(){
return "jdbc:sqlserver://"+serverName+":"+portNumber+";databaseName="
+databaseName+";responseBuffering=adaptive;selectMethod=cursor";
}
public java.sql.Connection getConnection(){
try{
...
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = java.sql.DriverManager.getConnection(getConnectionUrl(),userName,password); if (con.getAutoCommit())
{
con.setAutoCommit(false);
}
...
}
catch(Exception e){
System.out.println("etc, etc...");
}
return con;
}
The following is a loop where each loop represents a file in the folder:
File[] contenido = archivo.listFiles();
for(int i=0;i<contenido.length;i++)
{
if (contenido[i].isDirectory())
{
procesarDirectory(contenido[i]);
}else
{
insertDirectory(contenido[i]);
}
}
...And this is the insertDirectory procedure which inserts every file: the pdffile and pdffilenoperm are the IMAGE columns. The rest are varchar or int columns:
public void insertDirectorio(File archivo) {...if (archivo.isFile()){ pstmt =con.prepareStatement("INSERT INTO temp_carga "+ "(directory, name, dir_sup, filetype, pfilesize,pdffile,pdffilenoperm)"+ " values (?,?,?,?,?,?,?)"); }...
long tamano = archivo.length();
pstmt.setString(1,pdffile.getPath());
pstmt.setString(2,pdffile.getName());
pstmt.setString(3,pdffile.getParent());
pstmt.setString(4,filetype);
if (pfilesize != 0) {
pstmt.setLong(5,pfilesize);
}
else
{
pstmt.setString(5,null);
}
if (pdffile.isFile()) {
try{
//INSERTS ORIGINAL FILE................
int fileLength = Integer.MIN_VALUE;
is = new FileInputStream(pdffile);
fileLength= (int) pdffile.length();
pstmt.setBinaryStream(6, is, fileLength);
//INSERTS FILE WITHOUT PERMISSIONS
(THIS PART OF THE CODE IS LONG AND IRRELEVANT, IT JUST USES THE ITEXT LIBRARY TO MODIFY THE PDF FILE. AT THE END, I HAVE THE FILE IN AN OUTPUT STREAM, AS SHOWN HERE:)
ByteArrayInputStream inputnoimp = new ByteArrayInputStream(outnoimp.toByteArray());
pstmt.setBinaryStream(7,inputnoimp,(int)outnoimp.size());
} catch(Exception e) {
err = e.toString();
}
}
pstmt.executeUpdate();
con.commit();
pstmt.close();
this.closeConnection();
}catch(java.sql.SQLException e) {
err = e.toString();
}
}
Well, as I said, when I run the program, when it reads smaller files, there's no problem. But when it gets a big file, I get the OUT OF MEMORY error. I have another application that reads pdf files ONE AT A TIME, using a code very much like this one, and it reads big files (>30mb) with no problems. The problems is with this one.
Any help will be appreciated. If you have any question to clarify the problem, just tell me.
Thanks in advance.
Eric.
View 7 Replies
View Related
May 14, 2008
Hello All,i am trying to insert some values into a table in sql database. i keep getting error saying incorrect syntax near 'S'. i fired up my debugger and found that one of the row contains name like Georgia's way. i am getting error at the "S" in georgia's way. how can i fix that. here is my code for inserting the values in to the table SqlConnection mysqlcon = new SqlConnection(ConfigurationManager.ConnectionStrings["ImportexcelConnectionString"].ConnectionString); mysqlcon.Open(); foreach (DataRow dr1 in objDataSet.Tables[0].Rows) { String sqlinsert = String.Format("insert into Det values('{0}','{1}','{2}','{3}','{4}','{5}','{6}',{7},{8},'{9}','{10}','{11}','{12}')"
, dr1[0].ToString()
, dr1[1].ToString()
, dr1[2].ToString()
, dr1[3].ToString() -- this is the column where georgia's way is
, dr1[4].ToString()
, dr1[5].ToString()
, dr1[6].ToString()
, Convert.ToDecimal(dr1[7].ToString())
, Convert.ToDecimal(dr1[8].ToString())
, dr1[9].ToString()
, dr1[10].ToString()
, dr1[11].ToString()
, dr1[12].ToString());
new SqlCommand(sqlinsert, mysqlcon).ExecuteNonQuery(); LabelImport.Text = " Row Inserted"; } mysqlcon.Close(); can some please help me out.Thanks a lot
View 16 Replies
View Related
May 28, 2008
i use this statement to insert into sql tablecmdInsert = New SqlCommand("insert into empbill ([deptcode],[personNo,[entrydate]] ) values(" & Val(eno.Text) & "," & Val(TextBox5.Text) & ", " & dd.Text & "')", db)
cmdInsert.ExecuteNonQuery()
dd.Text value is 22/5/2008 it come from datetime calender
the entrydate field datatype is datetime
i found data always 1/1/1900 00:00:00
how i enter my date
View 10 Replies
View Related
Jun 11, 2008
Hi, Im struggling with this insert statement, I want to use with a AJAX validation Post Form page.
Its quite straght forward, if a search query returns null the insert these values. The search query does work, what I mean by that is that txt field values seem to pass for search but not insert. Any help out there cheers Paul if (RowCount == 0)
{String strSQL = "INSERT INTO Mail_List (FirstName, Email) VALUES( @FirstName, @Email )";
try
{mySqlConn = new SqlConnection(strSqlConn);
mySqlConn.Open();SqlCommand cmd = new SqlCommand();
cmd = new SqlCommand(strSQL, mySqlConn);cmd.Parameters.AddWithValue("@FirstName", Request.Form["FirstName"]);cmd.Parameters.AddWithValue("@Email", Request.Form["Email"]);
cmd.ExecuteNonQuery();
lblStatus.Text = "Registration Successful";
}
View 2 Replies
View Related
Jan 15, 2004
I would like to know what options I have with regards to trapping a duplicate record
before it tries to post to a SQL database. I have set the column to unique in SQL. But
when I try to use ASP and post a duplicate record I get a system error. I would like to
just create a referential error to notify the user that they cannot post a duplicate record
please try again. Any help would be greatly appreciated.
RT
View 1 Replies
View Related
Oct 7, 2004
I've just noticed some strange behavior that seems like a bug to me.
It's much easier to follow an example of it that to outright explain it, so here goes.
I have a table defined with a NOT NULL constraint on a column and a default clause:
-- DROP TABLE TestTable
CREATE TABLE TestTable ( TestField0 varchar(10), TestField1 varchar(10) NOT NULL DEFAULT ('a') )
I have a view defined on the table, in this example case, the view just mirrors the table one to one:
-- DROP VIEW TestView
CREATE VIEW TestView as SELECT TestField0, TestField1 FROM TestTable
So far so good, if I run this statement, it works as I would expect and inserts the value and the default goes into the other field:
INSERT INTO TestView (TestField0) SELECT 'test'
Now... If I add an INSTEAD OF trigger to the view, and have it perform the insert for me, I get an error with the same insert stmt:
-- DROP TRIGGER TestTrigger
CREATE TRIGGER TestTrigger ON TestView
INSTEAD OF INSERT AS
BEGIN
INSERT INTO TestTable (TestField0, TestField1)
SELECT TestField0, COALESCE(TestField1, 'X')
FROM inserted
END
Notice the trigger will ensure that a null value cannot be inserted into TestField1. If I run this insert stmt though I get an error:
INSERT INTO TestView (TestField0) SELECT 'test'
Server: Msg 233, Level 16, State 2, Line 1
The column 'TestField1' in table 'TestView' cannot be null.
Am I missing something or is this a bug?
Thanks
View 1 Replies
View Related
Feb 27, 2008
I have written following SQL query, this creates temporary table, inserts rows into it. I need to create VIEW "vw_NumberOfAttachments" in the database. I initially created table using "CREATE TABLE" but then i got error as VIEW can not be filled by temporary table. Hence I am using DECLARE TABLE
--------------------------------
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE sp_GetViewNumberOfAttachments
-- Add the parameters for the stored procedure here
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
DECLARE @emailMessageID bigint
DECLARE @metaDataStorageID bigint
DECLARE @numberOfAttachments int
DECLARE @AttachmentDetails TABLE
(
emailMessageID bigint,
metaDataStorageID bigint,
numberOfAttachments int
)
DECLARE ATTACHMENT_CURSOR CURSOR
FOR
SELECT emailMessageID, metaDataStorageID
FROM ppaEmailMessage
WHERE hasAttachments='true'
OPEN ATTACHMENT_CURSOR
FETCH NEXT FROM ATTACHMENT_CURSOR INTO @emailMessageID, @metaDataStorageID
WHILE @@FETCH_STATUS = 0
BEGIN
-- here the table name need to get dynamically the name of the attachment table
-- for a moment it is written as ppaMsOfficeDoc, but that should change dynamically
set @numberOfAttachments = (SELECT count(*) FROM ppaMsOfficeDoc WHERE metaDataStorageID = @metaDataStorageID)
INSERT INTO @AttachmentDetails(emailMessageID, metaDataStorageID, numberOfAttachments)
VALUES (@emailMessageID, @metaDataStorageID, @numberOfAttachments)
FETCH NEXT FROM ATTACHMENT_CURSOR INTO @emailMessageID, @metaDataStorageID
END
CLOSE ATTACHMENT_CURSOR
DEALLOCATE ATTACHMENT_CURSOR
IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS
WHERE TABLE_NAME = 'vw_NumberOfAttachments')
DROP VIEW vw_NumberOfAttachments
GO
CREATE VIEW vw_NumberOfAttachments
AS
SELECT @AttachmentDetails.emailMessageID, @AttachmentDetails.metaDataStorageID, @AttachmentDetails.numberOfAttachments
FROM @AttachmentDetails
GO
END
GO
----------------------
I am getting following errors:
-----------
Msg 102, Level 15, State 1, Procedure sp_GetViewNumberOfAttachments, Line 57
Incorrect syntax near 'vw_NumberOfAttachments'.
Msg 137, Level 15, State 2, Procedure vw_NumberOfAttachments, Line 3
Must declare the scalar variable "@AttachmentDetails".
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near 'END'.
-----------
Can anyone please suggest whats wrong in there? Many thanks
View 1 Replies
View Related
Oct 26, 2007
Hi guys,
I have created 3 tables namely Static, Dynamic and Demo...
Static has colums FormID(uniqueidentifier, PrimaryKey) and FormName(Nvarchar(50)).
Dynamic has colums formID(uniqueidentifier,PrimaryKey) and FormName(Nvarchar(50)).
Demo has 4 colums namely ValueID(uniqueidentifier, Primary Key), formID(uniqueidentifier, foreign key), Name(nvarchar(50)), Value(nvarchar(50).
Now the formID coloum in Demo table i have set as foreign key to both the dynamic table as well as static table on the formID colum in both table.
Now first i insert a row in the dynamic table then take the uniqueidentifier which is generated automatically and try
to insert in the Demo table in formID colum as that colum is FK to dynamic and static but when i try to insert a row it show that its violating the FOREIGN KEY CONSTRAINT
the exact error is
Msg 547, Level 16, State 0, Line 1
The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Demo_Dynamic1". The conflict occurred in database "huzefaJTest", table "dbo.Dynamic", column 'formid'.
The statement has been terminated.
please if anyone know do reply.....
View 3 Replies
View Related
Jul 13, 2007
string fileName = "d:\shiporder.xml";
DataSet dataSet = new DataSet();
dataSet.ReadXML(fileName);
//connection string
string cmd = "INSERT INTO Orders (OrderID, OrderPerson) VALUES (dataSet.Tables[0].Row[0][0].ToString(),dataSet.Tables[0].Row[0][1].ToString);
SqlConnection con = new SqlConnection(conection string);
SqlCommand mycmd = new SqlCommand(cmd,con);
con.Open();
mycmd.ExecuteNonQuery();
con.Close();
it gives me this error
dataSet.Tables its not permitted in this context. valid expression are constants, constant expression, . Columns name are not permitted
View 2 Replies
View Related