Inserting Blank Data In Sql Server Database - Why?!?!
Oct 23, 2006
Hi everyone!
Hope that someone can help me solving this problem.
I have a form where the user can register by putting his private data. Each time that he submits his data, if he is using Internet Explorer, it will insert blank data into sql server database. But if user is using Firefox, everything is working well, and all data is inserted.
What seems to be the problem?
Why in IE, data is inserted as blank?!
Thanks for your possible help and attention to this issue.
Hope that someone can help me.
Best regards,
Mesk
View 2 Replies
ADVERTISEMENT
Apr 13, 2007
when inserting or updating fields in sql server and the field is blank sql still adds several spaces into the field. Then if I try to check whether a field is empty or not for display I get incorrect results because fields that should be empty have 2 or 3 spaces in them instead and therefor aren't selected as being empty. Is there any way around this? to force the fields to be saved as blanks or null?
View 3 Replies
View Related
May 31, 2007
hi
I want to read data from XML file and insert that data from XML file into the Database Table From ASP.NET page.plz give me the code to do this using DataAdapter.Update(ds)
View 1 Replies
View Related
Feb 2, 2008
Hi,
I have a scenario where I want the current User to add details regarding their house in to my 'Property' table in my database and also store their uploaded picture in the same tabe when they press the 'Add Property' button. I also want to store the current Users ID in the 'Property' table so the property being added is assigned to the current user. Can anyone help me with the implementation of this? Here is the code I have so far:
property.aspx page:
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<span style="font-size: 16pt; font-family: Bradley Hand ITC"><strong>Add Property</strong></span><table style="border-right: silver 3px outset; border-top: silver 3px outset; left: 337px;
border-left: silver 3px outset; border-bottom: silver 3px outset; position: relative;
top: 9px">
<tr>
<td colspan="2">
<strong><span style="font-size: 14pt; font-family: Bradley Hand ITC">
Address</span></strong></td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="TownLabel" runat="server" Font-Bold="False" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="Town:" Width="97px"></asp:Label></td>
<td style="width: 100px">
<asp:TextBox ID="TownTextBox" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="CityLabel" runat="server" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="City:" Width="97px"></asp:Label></td>
<td style="width: 100px">
<asp:TextBox ID="CityTextBox" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="CountyLabel" runat="server" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="County:" Width="97px"></asp:Label></td>
<td style="width: 100px">
<asp:TextBox ID="CountyTextBox" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="CountryLabel" runat="server" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="Country:" Width="97px"></asp:Label></td>
<td style="width: 100px">
<asp:TextBox ID="CountryTextBox" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="PostcodeLabel" runat="server" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="Postcode:" Width="97px"></asp:Label></td>
<td style="width: 100px">
<asp:TextBox ID="PostcodeTextBox" runat="server"></asp:TextBox></td>
</tr>
</table>
<asp:Button ID="AddButton" runat="server" Text="Add Property" style="left: 378px; position: relative; top: 66px" /><tablestyle="border-right: silver 3px outset; border-top: silver 3px outset; left: 648px;
border-left: silver 3px outset; border-bottom: silver 3px outset; position: relative;
top: -190px">
<tr>
<td style="width: 186px">
<span style="font-size: 14pt; font-family: Bradley Hand ITC"><strong>Property Description</strong></span></td>
</tr>
<tr>
<td style="width: 186px">
<asp:TextBox ID="DescriptionTextBox" runat="server" Height="172px" Width="233px" TextMode="MultiLine"></asp:TextBox></td>
</tr>
</table><asp:FileUpload ID="PropertyPicture" runat="server" Style="left: 356px; position: relative;
top: -214px" />
<asp:SqlDataSource ID="AddProperty" runat="server" ConnectionString="<%$ ConnectionStrings:My Property PortfolioConnectionString %>"ProviderName="<%$ ConnectionStrings:My Property PortfolioConnectionString.ProviderName %>"
InsertCommand="INSERT INTO Property(User_ID, Property_type, Property_Name, Number_of_Rooms, Sleeps, Town, City, County, Country, Postcode, Description, Facility1, Facility2, Picture)
VALUES (@User_ID, @Property_type, @Property_Name, @Number_of_Rooms, @Sleeps, @Town, @City, @County, @Country, @Postcode, @Description, @Facility1, @Facility2, @Picture)">
<InsertParameters>
<asp:SessionParameter Name="User_ID" />
<asp:ControlParameter ControlID="TypeDropDownList" Name="Property_type" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="PropertyNameTextBox" Name="Property_Name" PropertyName="Text" />
<asp:ControlParameter ControlID="NoOfRoomsDropDownList" Name="Number_of_Rooms" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="SleepsDropDownList" Name="Sleeps" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="TownTextBox" Name="Town" PropertyName="Text" />
<asp:ControlParameter ControlID="CityTextBox" Name="City" PropertyName="Text" />
<asp:ControlParameter ControlID="CountyTextBox" Name="County" PropertyName="Text" />
<asp:ControlParameter ControlID="CountryTextBox" Name="Country" PropertyName="Text" />
<asp:ControlParameter ControlID="PostcodeTextBox" Name="Postcode" PropertyName="Text" />
<asp:ControlParameter ControlID="DescriptionTextBox" Name="Description" PropertyName="Text" />
<asp:ControlParameter ControlID="Facility1DropDownList" Name="Facility1" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="Facility2DropDownList" Name="Facility2" PropertyName="SelectedValue" />
<asp:Parameter Name="Picture" />
</InsertParameters>
</asp:SqlDataSource>
<table style="left: 12px; position: relative; top: -411px; border-right: silver 3px outset; border-top: silver 3px outset; border-left: silver 3px outset; border-bottom: silver 3px outset;">
<tr>
<td colspan="2">
<strong><span style="font-size: 14pt; font-family: Bradley Hand ITC">
Property Details</span></strong></td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="PropertyName" runat="server" Font-Bold="False" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="Property Name:" Width="101px"></asp:Label></td>
<td style="width: 100px">
<asp:TextBox ID="PropertyNameTextBox" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="NoOfRooms" runat="server" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="No of Rooms:" Width="97px"></asp:Label></td>
<td style="width: 100px">
<asp:DropDownList ID="NoOfRoomsDropDownList" runat="server">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
<asp:ListItem>7</asp:ListItem>
</asp:DropDownList></td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="Sleeps" runat="server" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="Sleeps:" Width="97px"></asp:Label></td>
<td style="width: 100px">
<asp:DropDownList ID="SleepsDropDownList" runat="server">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
<asp:ListItem>7</asp:ListItem>
<asp:ListItem>8</asp:ListItem>
<asp:ListItem>9</asp:ListItem>
<asp:ListItem>10</asp:ListItem>
<asp:ListItem>11</asp:ListItem>
<asp:ListItem>12</asp:ListItem>
</asp:DropDownList></td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="Type" runat="server" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="Type:" Width="97px"></asp:Label></td>
<td style="width: 100px">
<asp:DropDownList ID="TypeDropDownList" runat="server">
<asp:ListItem>Bungelow</asp:ListItem>
<asp:ListItem>Appartment</asp:ListItem>
<asp:ListItem>Flat</asp:ListItem>
<asp:ListItem>Studio</asp:ListItem>
<asp:ListItem>Cottage</asp:ListItem>
<asp:ListItem>House</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="Facility1" runat="server" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="Facility 1:" Width="97px"></asp:Label></td>
<td style="width: 100px">
<asp:DropDownList ID="Facility2DropDownList" runat="server">
<asp:ListItem>Air conditioning</asp:ListItem>
<asp:ListItem>Dishwasher</asp:ListItem>
<asp:ListItem>En-suit</asp:ListItem>
<asp:ListItem>Garage</asp:ListItem>
<asp:ListItem>Garden</asp:ListItem>
<asp:ListItem>Internet</asp:ListItem>
<asp:ListItem>Pool</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="Facility2Label" runat="server" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="Facility 2:" Width="97px"></asp:Label></td>
<td style="width: 100px">
<asp:DropDownList ID="Facility1DropDownList" runat="server">
<asp:ListItem>Pool</asp:ListItem>
<asp:ListItem>Air conditioning</asp:ListItem>
<asp:ListItem>Dishwasher</asp:ListItem>
<asp:ListItem>En-suit</asp:ListItem>
<asp:ListItem>Garage</asp:ListItem>
<asp:ListItem>Garden</asp:ListItem>
<asp:ListItem>Internet</asp:ListItem>
</asp:DropDownList></td>
</tr></table>
</asp:Content>
property.aspx.vb page:Partial Class Default2
Inherits System.Web.UI.PageProtected Sub AddButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles AddButton.Click
AddProperty.Insert()End Sub
End Class
Many Thanks
View 2 Replies
View Related
Dec 10, 2005
4 Layered Web Application for Inserting data into a database using sql server as the back end and a web form as the front end using C# .
Can someone provide with code as I am new to this architecture and framework.
Better send email.
Thanks In Advance,
A New Bie
View 1 Replies
View Related
Jul 23, 2005
I'm doing a bcp out of a table to a file. Some of the fields in arecord may have an empty string.When I bcp out to the file and examine it, the fields that have anempty string in the database now show up in the file as having oneblank character.Why is bcp doing this? I don't want the blank character in my output.Thanks,Eric
View 4 Replies
View Related
Aug 7, 2007
Hello friends....
I am looking for 2 things(using c#.net or vb.net and sql svr 2000)
1.convert data from sql server 2000 database (say customers table from northwinds database) to a text file(separated by commas or just plain space)
2.Insert the data from text file back to database.
Can someone pls give me the detailed code to achieve this....really need this on urgent basis.......Thank You.
View 10 Replies
View Related
Jan 5, 2007
Hi,
I am just wondering if anyone could let me know what happens in a SQL Server job step if the "Database" field is left blank?
Regardless of whether or not it's blank does it use some sort of database as its default?
If anyone could pont me to any material on the web it would be much appreciated.
Many Thanks,
View 1 Replies
View Related
Feb 28, 2008
Hi iam working with the form which has fields like AuditName,Industry Name,Company Name,Plant Name,Group Name,AuditStartedOn,Auditperiod upto,CreatedOn,createdby
I have dropdownlists for Industry Name,Company Name,Plant Name,Group Name.Data will be filled into Industry Name,Group Name when pageloads from the database and later depending on industryname company name and depending on company name plant name ddl's wiil be filled.
Later to insert this into the Audit table i had given the Stored procedure as :
create procedure CreateAudit
(
@AuditName nvarchar(50),
@IndustryName nvarchar(50),
@IndustryID int output,
@CompanyName nvarchar(50),
@CompanyID int output,
@PlantName nvarchar(50),
@PlantID int output,
@GroupName nvarchar(50),
@GroupID int output,
@AuditStartedOn datetime,
@AuditScheduledto datetime,
@CreatedOn datetime,
@CreatedBy int
)
as
begin
//Here iam getting the Id of the industryname selected in the ddl from industry table into an output parameter @IndustryID
select @IndustryID=Ind_Id_PK from Industry where Industry_Name=@IndustryName
//Here iam getting the Id of the companyname selected in the ddl from company table into an output parameter @CompanyID
select @CompanyID=Cmp_ID_PK from Company where Company_Name=@CompanyName
//Here iam getting the Id of the plantname selected in the ddl from plant table into an output parameter @PlantID
select @PlantID=Pl_ID_PK from Plant where Plant_Name=@PlantName
//Here iam getting the Id of the Groupname selected in the ddl from Group table into an output parameter @GroupID
select @GroupID=G_ID_PK from Groups where Groups_Name=@GroupName
Insert into Audits(Audit_Name,Audit_Industry,Audit_Company,Audit_Plant,Audit_Group,Audit_Started_On,Audit_Scheduledto,Audit_Created_On,Audit_Created_By)values(@AuditName,@IndustryID,@CompanyID,@PlantID,@GroupID,@AuditStartedOn,@AuditScheduledto,@CreatedOn,@CreatedBy)
end
Later called these parameters into class file:
namespace xyz{
public class clsCreateAudit
{SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["constr"]);
SqlCommand cmd = new SqlCommand();SqlDataAdapter da = new SqlDataAdapter();public clsCreateAudit()
{
con.Open();
}public void CreateAudit(string Audit_Name, int Audit_Industry, int Audit_Company, int Audit_Plant, int Audit_Group, DateTime Audit_Started_On, DateTime Audit_Scheduledto, DateTime Audit_Created_On, string Audit_Created_By)
{
cmd.Connection = con;cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "CreateAudit";
SqlParameter AuditName = new SqlParameter();AuditName.ParameterName = "@AuditName";AuditName.DbType = DbType.String;
AuditName.Value = Audit_Name;AuditName.Direction = ParameterDirection.Input;
cmd.Parameters.Add(AuditName);
SqlParameter AuditIndustry = new SqlParameter();AuditIndustry.ParameterName = "@IndustryName";AuditIndustry.Direction = ParameterDirection.Input;
AuditIndustry.Value = Audit_Industry;AuditIndustry.DbType = DbType.String;
cmd.Parameters.Add(AuditIndustry);
SqlParameter IndustryID = new SqlParameter();IndustryID.ParameterName = "@IndustryID";
IndustryID.Direction = ParameterDirection.Output;IndustryID.DbType = DbType.Int32;
//IndustryID.Size = 100;
cmd.Parameters.Add(IndustryID);SqlParameter AuditCompany = new SqlParameter();
AuditCompany.ParameterName = "@CompanyName";AuditCompany.Direction = ParameterDirection.Input;
AuditCompany.Value = Audit_Company;AuditCompany.DbType = DbType.String;
cmd.Parameters.Add(AuditCompany);SqlParameter CompanyID = new SqlParameter();
CompanyID.ParameterName = "@CompanyID";CompanyID.Direction = ParameterDirection.Output;
CompanyID.DbType = DbType.Int32;
//IndustryID.Size = 100;
cmd.Parameters.Add(CompanyID);
SqlParameter AuditPlant = new SqlParameter();
AuditPlant.ParameterName = "@PlantName";AuditPlant.Direction = ParameterDirection.Input;
AuditPlant.Value = Audit_Plant;AuditPlant.DbType = DbType.String;
cmd.Parameters.Add(AuditPlant);SqlParameter PlantID = new SqlParameter();
PlantID.ParameterName = "@PlantID";PlantID.Direction = ParameterDirection.Output;
PlantID.DbType = DbType.Int32;
//IndustryID.Size = 100;
cmd.Parameters.Add(PlantID);SqlParameter AuditGroup = new SqlParameter();
AuditGroup.ParameterName = "@GroupName";AuditGroup.Direction = ParameterDirection.Input;
AuditGroup.Value = Audit_Group;AuditGroup.DbType = DbType.String;
cmd.Parameters.Add(AuditGroup);SqlParameter GroupID = new SqlParameter();
GroupID.ParameterName = "@GroupID";GroupID.Direction = ParameterDirection.Output;
GroupID.DbType = DbType.Int32;
//IndustryID.Size = 100;
cmd.Parameters.Add(GroupID);SqlParameter AuditStartedOn = new SqlParameter();
AuditStartedOn.ParameterName = "@AuditStartedOn";AuditStartedOn.Direction = ParameterDirection.Input;
AuditStartedOn.Value = Audit_Started_On;AuditStartedOn.DbType = DbType.String;
cmd.Parameters.Add(AuditStartedOn);SqlParameter AuditScheduledto = new SqlParameter();
AuditScheduledto.ParameterName = "@AuditScheduledto";AuditScheduledto.Direction = ParameterDirection.Input;
AuditScheduledto.Value = Audit_Scheduledto;AuditScheduledto.DbType = DbType.String;
cmd.Parameters.Add(AuditScheduledto);SqlParameter CreatedOn = new SqlParameter();
CreatedOn.ParameterName = "@CreatedOn";CreatedOn.Direction = ParameterDirection.Input;
CreatedOn.Value = Audit_Created_On;CreatedOn.DbType = DbType.String;
cmd.Parameters.Add(CreatedOn);SqlParameter CreatedBy = new SqlParameter();
CreatedBy.ParameterName = "@CreatedBy";CreatedBy.Direction = ParameterDirection.Input;
CreatedBy.Value = Audit_Created_By;CreatedBy.DbType = DbType.Int32;
cmd.Parameters.Add(CreatedBy);
cmd.ExecuteNonQuery();
con.Close();
}
}
}
Then i called these function into .aspx.cs file:
using xyz;protected void btn_CreateAudit_Click(object sender, EventArgs e)
{SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["constr"]);
PCRA.clsCreateAudit obj = new PCRA.clsCreateAudit();
SqlCommand cmd = new SqlCommand();
//Iam getting the Session(UID) from my login page.obj.CreateAudit(txt_AuditName.Text, Convert.ToInt32(ddl_Industry.SelectedItem.Value), Convert.ToInt32(ddl_Company.SelectedItem.Value), Convert.ToInt32(ddl_Plant.SelectedItem.Value), Convert.ToInt32(ddl_Group.SelectedItem.Value), Convert.ToDateTime(txt_StartingOn.Text.ToString()), Convert.ToDateTime(txt_AuditPeriod.Text.ToString()), System.DateTime.Now, Session["UID"].ToString());lbl_Mesg.Text = "Your Audit Details are added succesfully";
}
But iam getting an error here near obj.CreateAudit as:
Input string was not in a correct format.
I even want to know if my storedprocedure reaches the requirement which i specified.
please help me with this.Its very urgent.
View 1 Replies
View Related
Apr 9, 2008
I have table in my SQL db
I am inserting value using insert statement
Following are statement which I am using when inserting data into database
INSERT INTO EMPLOYEE (NAME, TELEPHONE, PINNUM,CELLNUM)
SELECT NAME,TELEPHONE,PINNUM FROM EMPLOYEE WHERE EMPLOYEEID=1
Noticed that I dont have CELLNUM In my select statment, but I want to insert that number from textbox which I have on my webform.
can some one tell me how do i do this query so i can insert data into database.
HELP ME
thank u
maxs
View 6 Replies
View Related
May 3, 2007
Hey guys, i finally connected to the db fine however for some reason i cannot pull the data. I was hoping somebody here might be able to help me. The code is below
Function MyQueryMethod() As System.Data.DataSet Dim connectionString As String = "server='xxxx'; user id='xxxx'; password='xxxxxx'; database='wel"& _ "sh_indiv'" Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)
Dim queryString As String = "SELECT [test12].[name], [test12].[grade] FROM [test12]" Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand dbCommand.CommandText = queryString dbCommand.Connection = dbConnection
Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.SqlClient.SqlDataAdapter dataAdapter.SelectCommand = dbCommand Dim dataSet As System.Data.DataSet = New System.Data.DataSet dataAdapter.Fill(dataSet)
Return dataSet End Function
im kinda new to programming with vb for asp.net pages so please bare with me.
View 2 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
Sep 11, 2007
Hi all, I want to insert some data that from a table into a database, and I got the error message-- "The variable name '@IssueID' has already been declared. Variable names must be unique within a query batch or stored procedure." Is it anything wrong with my code? Thanks a lot.
Dim row As Data.DataRow
For Each row In table.Rows
DataSource.InsertParameters.Add("IssueID", row(0)) DataSource.InsertParameters.Add("UserName", Session("loginName")) DataSource.InsertParameters.Add("IssueCost", row(1)) DataSource.InsertParameters.Add("IssueDesc", row(2))
DataSource.Insert()
Next row
View 4 Replies
View Related
Jan 3, 2001
How can i insert test Data in to the Database,I want to insert one million records in to the table,This is to test Database Performance.
Can anyone help me in this regard,Do we have any scripts for this purpose???
thanks
Mar
View 4 Replies
View Related
Jul 20, 2005
Hello, is it possible to insert new data into a datbasealphabetically? For example when a user enters a new row of data, Iwant the row inserted in the correct order. I do not think this ispossible.Thank you for the help!
View 1 Replies
View Related
Aug 22, 2006
Hi everyone,
I need to save the ascii data in my sql express 2005 database in one table and in 2 coloums in this table using VB express...
Can I do it by datareader or with bulk insert t-sql command?
I tried it this way but it gives error like "connection property is not initialised" it is on executenonquery row in the code...
Dim cmd = New SqlCommand("BULK INSERT RFID.dbo.stock(material_number,total) FROM 'C:can1.txt' " & _
"WITH FIELDTERMINATOR = ',', ROWTERMINATOR = '' ")
connection.Open()
cmd.executenonquery()
connection.Close()
I hope some can help with this problem....
View 6 Replies
View Related
Feb 21, 2007
I am trying to implement a code behind page (in VB) to insert data into a sql express database but something is not right. Any help would be greatly appreciated. The following is the code I have:Protected Sub SaveButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SaveButton.Click Dim connString As String = "Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|News.mdf;Integrated Security=True;User Instance=True;Asynchronous Processing=true" Dim sqlInsert As String = "INSERT INTO news_Article (Heading, Story, Author, Show_on_homepage) VALUES(@heading, @story, @author, @show)" Dim conn As New System.Data.SqlClient.SqlConnection(connString) Dim cmd As New System.Data.SqlClient.SqlCommand(sqlInsert, conn) Dim heading = HeadingTextBox.Text Dim story = StoryEditor.Value Dim author = AuthorTextBox.Text Dim show = ShowHPCheckBox.Checked conn.Open() cmd.BeginExecuteNonQuery() conn.Close()End Sub
View 4 Replies
View Related
Jun 5, 2007
what i understand if if the data field is integer or money, not string, then i need to do a convert(datatype, value) in the insert but how come its still not working INSERT INTO [Product] ([Title], [Description], [Processor], [Motherboard], [Chipset], [RAM], [HDD], [OpticalDrive], [Graphics], [Sound], [Speakers], [LCD], [Keyboard], [Mouse], [Chassis], [PSU], [Price]) VALUES (@Title, @Description, @Processor, @Motherboard, @Chipset, @RAM, @HDD, @OpticalDrive, @Graphics, @Sound, @Speakers, @LCD, @Keyboard, @Mouse, @Chassis, @PSU, convert(smallmoney, @Price))
View 1 Replies
View Related
Mar 26, 2008
i am creating a database driven website and i am using a sql database. I have a database called company with fields in it to do with a company, I have created a company.cs file which sets the variables, properties and methods and so on. These work fine. I have also stored procedures and they are right as far as i know. i also have coding behind the buttons of my page when i try and update or insert to the database. I am having the problem of when i enter data into the text boxes and click update, nothing gets inserted or updated and whats worst of all no error message appears. The table is used for storing profile data about a user, when a user logs on they enter their profile data, if i manually enter this data and input the username of a user into the username field within the database then the data appears fine in the textboxes of the update info page but the data will not insert or update. i have checked all the little things and i am stressing out cos i am running out of time and cannot find the problem...........please could someone help me!!!!! thanks
Heres my coding to some of my pages to help you....
the code behind the button
using System;
using System.Data;
using System.Configuration;
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 FYPtestsite.Classes;
public partial class Employer_employerprofile : System.Web.UI.Page
{protected void Page_Load(object sender, EventArgs e)
{if (!Roles.IsUserInRole(ConfigurationManager.AppSettings["employerrole"]))
{Response.Redirect("~/Error1.aspx");
}Company objCompany = Company.GetCompany(Profile.UserName);if (objCompany != null)
{
txtCompanyname.Text = objCompany.Companyname;
txtAddress1.Text = objCompany.Address1;
txtAddress2.Text = objCompany.Address2;
txtPostcode.Text = objCompany.Postcode;
txtCity.Text = objCompany.City;
txtPhone.Text = objCompany.Phone;
txtFax.Text = objCompany.Fax;
txtEmail.Text = objCompany.Email;
txtURL.Text = objCompany.URL;
txtProfile.Text = objCompany.Profile;
}
}protected void Button2_Click(object sender, EventArgs e)
{Response.Redirect("~/homepage.aspx");
}protected void Button3_Click(object sender, EventArgs e)
{Company objCompany = new Company();
objCompany.UserName = Profile.UserName;
objCompany.Companyname = txtCompanyname.Text;
objCompany.Address1 = txtAddress1.Text;
objCompany.Address2 = txtAddress2.Text;
objCompany.Postcode = txtPostcode.Text;
objCompany.City = txtCity.Text;
objCompany.Phone = txtPhone.Text;
objCompany.Fax = txtFax.Text;
objCompany.Email = txtEmail.Text;
objCompany.URL = txtURL.Text;
objCompany.Profile = txtProfile.Text;
if (Profile.Employer.CompanyID != -1)
{objCompany.CompanyID = (int)Profile.Employer.CompanyID;Company.Update(objCompany);
}
else
{int i = Company.Insert(objCompany);
Profile.Employer.CompanyID = i;
}labelstatus.Text = "Your profile has been successfully updated";
}
}
Any help would be greatly greatly appreciated!!!!!!
View 10 Replies
View Related
Nov 19, 2004
Hi! I have a vb.net program that writes data to an SQL Server database using ADODB. The problem is if I put the code that writes data to the database in between BeginTrans() and CommitTrans(), the database is not updated. Here is the flow of my program:
Dim connection as ADODB.Connection
'setup the connection to the SQL Server database here
connection.BeginTrans()
InsertData() ' --> data is written to the database
' this function works properly
connection.CommitTrans()
If I comment out the BeginTrans() and CommitTrans() functions, the data is properly inserted into the database.
Does an SQL Server database requires special settings to support transactions?
Please help.
And thank you in advance.
View 3 Replies
View Related
Jul 10, 2014
I have question on lock on table in SQL Server while inserting data using multiple processes at a single time into same table.Here are my questions on this,
1) Is it default behavior of SQL server to lock table while doing insert?
2) if yes to Q1, then how we can implicitly mention while inserting data.
3) If I have 4 tables and one table is having foreign keys from rest of the 3 tables, on this scenario do I need to use the table lock explicitly or without that I can insert records into those tables?
View 1 Replies
View Related
Jul 23, 2005
I developed a console application that will continually check a messagequeue to watch for any incoming data that needs to be inserted into MSSQL database.What would be a low-cost method I could use inside this consoleapplication to make sure the MS SQL database is operational before Iperform the insert?
View 7 Replies
View Related
May 1, 2012
I have two databases im working with, one is our public database GRM_Public, and the other is our production database GRM_Prod.
I'm trying to import data from a field called 'oldscreencodes1' from GRM_Prod.Transfer table into a field called 'Sale1Type' in GRM_Public.Real_land table.
For some reason I can't get this to work, I have in the past imported datatables from our production DB to our public DB by using 'insert into' but I've never inserted data into a single field within a datatable and I think I'm over thinking this process.
Is a 'join' necessary in order to accomplish this?
View 6 Replies
View Related
Nov 11, 2014
I have 2 tables in my database.
one is Race table and 2nd one is Age Range.
I want to write a query where I can see all races and age range as column.
TblRace
ID, RaceName
TblAgeRange
ID,AgeRange.
There is no connection between this two table. I need to display result like below.
Race 17-20 21-30 31-40
A
B
I
W
How do i get this kind of empty data set so that I can fill it out in front end or any better solution. The age range will be displayed as many row as they have. It's not static. Above is just an example.
View 1 Replies
View Related
Oct 8, 2007
I am trying to transition from Access to MS SQL. I downloaded and installed MS SQL 2005 Express and the Server Management Studio Express. Keep in mind that I am a total newbie to this database since I've always used Access. My question is, how do I insert data manually into my tables? I figured out how to set up a table and query a table, but is there somewhere I can just plug in data? In Access, I just open the table and type it in. Also, how do you set an auto increment numeric field in a table?- Jason
View 4 Replies
View Related
Jun 1, 2000
declare @counter int
select @counter=300000
while @counter > 0
begin
insert into Revenue (Instr_type, Tel_no, Phone_Id, Rpt_date, Pay_mode)
values("PP0073", @counter, "080464", "19990901", 1)
select @counter=@counter-1
end
HI there,
I run the above statement in Query Analyzer and the expected result should be 300,000 records inserted into Revenue table. But unfortunately the actual records inserted were less than 300,000. I also realise that it insert different amount of record each time I run it. Can anyone please tell me why?
Thanks,
Will
View 2 Replies
View Related
Jan 21, 2001
Hi...
I have some problems with inserting data from one SQL Server to another SQL Server in a scheduled time...
Please help me......
Eva
View 1 Replies
View Related
Sep 22, 2000
Hi, Everybody:
Could anyboby please tell me any way which can quickly inserting large data to SQL Server except using cursor?
Every morning, I use DTS to transfer around 100,000 data from foxpro to SQL Server 7.0 temporary table. Then I use cursor to check if the data already exist in the SQL Server table, then I do update; if the data does not exist in the SQL Server table, then I do insert into. In SQL Server database, each table already has over million record, also I have 12 table with the same situation.
Now I find cursor very slow to do above, can anybody tell me any way which can quickly to do update and insert?
Thank you very much.
View 3 Replies
View Related
Jul 16, 2007
Hello all,
I'm using sqlserver 2005 express edition. I'm working in an application which has the functionality of inserting datas from the excel file to sql server 2005 database.
Can anyone please guide me for performing this task.
Thanks in advance.
Ravirajdanasekaran
View 1 Replies
View Related
Mar 12, 2008
Hi,
Just look at my Code:protected void Button1_Click(object sender, EventArgs e)
{SqlConnection Conn = new SqlConnection("MyConnectionString");
SqlCommand Cmd = new SqlCommand();string linktext,headline, quote, para1, para2, para3;
linktext = this.TextBox1.Text;headline = this.TextBox1.Text;
quote = this.TextBox2.Text;para1 = this.TextBox3.Text;
para2 = this.TextBox4.Text;para3 = this.TextBox5.Text;Cmd.CommandText = "insert into desieyenews(linktext,newsheadline,quote,para1,para2,para3) values ("+linktext+","+headline+","+quote+","+para1+","+para2+","+para3+")";
Cmd.Connection = Conn;
Conn.Open();
Cmd.ExecuteNonQuery();
Conn.Close();
}
Details: In the above code I am inserting data from 5 textbox to my databse. It works fine but when I am trying to insert text like Tom's..., problem occurs. Whenever I am trying to insert some text with a single quote, the problem arises. Although the datatype of my database is text in MS SQL Server 2005.
Please give me some solution so that I can get rid of this problem....
Thanks in advance.
Tapas
View 4 Replies
View Related
May 15, 2015
I am using SQL Server report 2008/2012 (SSRS) and my report viewer contains body content with 3 Row groups.
While printing the report, data print with blank space and move to continue data to next page.
Departure flight : 70 rows
First Page : 42 rows printed
Second Page : 23 rows printed [ Supposed to be print 28 , if the total count of records more than 23 and less than 42 then the page print only 23 records ]
Third Page : 5 rows printed
Departure flight : 42 rows
First Page : 42 rows printed [Report max. record allowed to print 42 rows so if total record is 42 then print perfectly ]
Departure flight : 26 rows
First Page : 23 rows printed [Supposed to be print 26, if the total count of records more than 23 and less than 42 then the page print only 23 records ]
Second Page : 3 rows printed
View 3 Replies
View Related
Jun 19, 2005
How to insert a picture into SQL Server 2000 table?
I want
1)Table structure.
2)Insert statement.
3)One example.
View 1 Replies
View Related
Aug 12, 2015
I am trying to insert a value in the table. Sometimes the value has this symbol at the end. I just want insert the entire value except this symbol. The values can be like this that I am insert in the table
Insert into Table1(col1)
Values (12345§ )
The values can be, below is just an example
12345§
3456DER§
5678D
FGR564
I want to insert only these values from the above data
12345
3456DER
5678
FGR564
View 6 Replies
View Related