Help With Inserting Data (and A Picture) Into My Sql Server 2005 Database

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>

&nbsp;

<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>&nbsp;

</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>&nbsp;

</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


ADVERTISEMENT

Inserting Picture Into SQL Server Database Through Table

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

What Are Video's And Picture's Data Types, And How To Insert And Select Them Into Sql Database

Apr 8, 2008

I would like to create a table which can store a VLOB or BLOB.. which are pictures and images.. How do I insert them into the database and how do I select them into the data base for playing in a media player


I really do not have a background on this.. much.. I just know how to connect to a database and insert texts.. and updating and stuffs...

View 3 Replies View Related

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

ASP.NET +Inserting Data From Xml In SQL Server Database Table From ASP.NET

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

Problem Inserting Data Into SQL Server 2005 DB From WebForm Controls

Mar 30, 2007

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

View 2 Replies View Related

How To Check Integrity Of Data Exported From Csv Before Inserting In Sql Server 2005

Nov 26, 2007

Hi Friends,
I am Ravi, I need a help.
My case is like.. i need to upload data from csv file into sql server 2005 data table.
but before that I need to check integrity of data
for example:
let us say csv data is like
ISD CODE,STATE,NAME,QUALIFICATION
91,AP,KIRAN,MCA
01,MC,MIKE,MS
 
here i have to check that, wether there is an entry in ISD codes table for 91 and 01 (india and us)
similarly AP , MC (Andhra Pradesh and MISSICippi)
please suggest me a nice approach, no of records in ISD codes and States will 350-450 records.
 
thanks in advance
Ravi K

View 3 Replies View Related

How Can I Get Identitiy Field From Database While Inserting New Row In Sql Server 2005 Compact Edition

Aug 2, 2007



How Can I get Identitiy field from database while inserting new row in sql server 2005 compact edition.

Ex:

I am inserting row in a table through SqlQuery ("insert into ....") in which one of the field is of type Identity which generates number automatically. I want that number to pick up that number and used it in child table....


Any solution for it.


View 10 Replies View Related

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

Dec 10, 2005

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

View 1 Replies View Related

Inserting Picture In Report Builder Report

Jul 18, 2007

Hi everyone,

I want my users to be able to insert the logo when they create reports using report builder. Documentation tells that under Insert tab you can click on "Picture" and then browse to the location of the file and insert a picture. But I dont see "Picture" option under Insert menu. I only see 3 options "text box","Filter Description" and "Total Row Count".



Any Idea???



Thanks

Ashwini

View 8 Replies View Related

Picture In Database

Dec 28, 2006

Can i put picture in sql server database but not filename and path. I wantto put complete picture in field in database. Is it possible?

View 2 Replies View Related

Picture Name In Database Show In Asp.net 2.0

Apr 9, 2007

Hi,
 My question is how can i get a page show all of my pictures i got in folder c:..Images? by using Database. Becouse I want some of the pictures to be shown in one page for theirselves.
Database looks like:
ID     |   Pname    |   Pact    |
1      |    picture1  |   Yes     |
2      |    picture2  |   No       |   etc.
 Now i want picture 1 and 2 to be shown in my Allpictures.aspx
I tried by using <asp:repeater...>... But i got a problem when i wanted the <img src=<%#EVAL(Pname)/>... becouse i cant do it that way...
 Thanks,
Even Knutli

View 2 Replies View Related

Saving Picture In A SQL Database (ASP.NET 2.0/C#)

Dec 1, 2005

I'm looking for information that could tell me how to saving picture in a SQL database. The site is build on asp.net 2.0 and c#, and I'm using Visual Web Developer 2005 Express Edition. I would be thankful for some help.

View 1 Replies View Related

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

Aug 7, 2007

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

View 10 Replies View Related

Saving Uploaded Picture Filepath To Sql Database

Oct 13, 2007

I am trying to save an uploaded picture filepath to a sql database record.  The record that the filepath will be saved to will be the record determined by the logged in userid.  I get an error stating Object not set to an instance of an object.  This is my code for when the upload button is hitProtected Sub uploadbutton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles uploadbutton.Click
If UploadTest.HasFile = False Then
' No file uploaded!
UploadDetails.Text = "Please first select a file to upload..."
Else
' Display the uploaded file's detailsUploadDetails.Text = String.Format( _
"Uploaded file: {0}<br />" & _"File size (in bytes): {1:N0}<br />" & _"Content-type: {2}", _
UploadTest.FileName, _
UploadTest.FileBytes.Length, _
UploadTest.PostedFile.ContentType)
' Save the fileDim filePath As String =  Server.MapPath("~/ProfilePictures/" & UploadTest.FileName)
UploadTest.SaveAs(filePath)Dim datasources1 As New SqlDataSourcedatasources1.ConnectionString = ConfigurationManager.ConnectionStrings("aspnetdb_connection").ToString()
datasources1.UpdateCommandType = SqlDataSourceCommandType.Text
Dim myUserID As String = Membership.GetUser().ProviderUserKey.ToStringdatasources1.UpdateParameters("userid").DefaultValue = myUserID
datasources1.UpdateCommand = "UPDATE into profile_details (pic) VALUES (@filepath) WHERE ([UserId] = @UserId)"
End If
End Sub
 
Any ideas on what i need to do to fix this?

View 5 Replies View Related

How Do I Store An Image/photo/picture In A Database?

Oct 24, 2000

How do I store an image/photo/picture in a database?

I have a database called database1 with a table called table1 like:

Table1:
Personid Name1 Name2 Address

and I want to stora a picture of the person in the database (SQL Sever 7) c:picture.jpg. How could I do that? I would like to use a stored procedure to do it. Something with BLOB?bulk insert? how does it work?

Thanks for you help!

//Carl

View 1 Replies View Related

Adding Image Or Picture To A Database Record

Jun 17, 2007

Hi,

I am new to SQL Server and I have got this problem and I am wondering if anyone could provide me with a solution, please.

I created a Product database table using Visual Basic 2005 Express and SQL Server 2005 Express. I have just added a new column [Picture] with IMAGE datatype to the database table, which of course, should store an image or picture of a product. I am writing to kindly ask you guys for help.

i) How do I store a picture or image for each record of this column [Picture] of database table? I have tried and all that I can see is < binary data > in the picture column, and when I start the VB 2005 Express form is a blank picture box!

ii) How do I get this image to display on Visual Basic 2005 Express form, so that when a product is selected the product image is displayed too? All text data appears but not the picture!

Your help much appreciated. Thanks.

Paul

View 3 Replies View Related

Regarding Inserting Data From GUI To Database

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

INSERTING DATA INTO SQL DATABASE

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

Error While Inserting Data In DataBase ?

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

Problems On Inserting Data Into Database

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

Inserting Test Data In To The Database

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

Inserting Data Into A Database Alphabetically

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

Inserting Ascii Data Into SQL Database

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

Inserting Text Into SQL 2005 Database Padded With Spaces

Jan 2, 2007

I have a Detailsview with Insert and Update options connected to a SQL 2005 table with templated textboxes for input. The textboxes have maxlength set to the number of characters in each respective field in the SQL 2005 table. When text is inserted it gets padded with spaces if all the field length is not used. When you try to edit the field the cursor does not move because of the padded spaces. The End key must be pressed to find the end of the string and the padded space removed before adding edited text. I am working in VB.net. If I check the field in SQL Studio Express is shows the text I typed plus blank space for the remainder of the field.
My question is how can I add text to the textboxes without the padded spaces being added when the maxlength of the field is not used?

View 3 Replies View Related

Inserting Data In SQL 2005 Using Javascript From A Form Object

Mar 4, 2008

I am new to ASP.NET. At present i am developing a web application in which i need to insert data in database(MS SQL 2005) from a form which uses only HTML controls. I need to use HTML controls so posting of form to the server is not done and hence i need to generate HTML controls using javascript. So the data in the form must be stored in the database. How this data can be inserted in the database is the problem and i think that javascript might be the solution for it.
 
Sagar 

View 3 Replies View Related

Problem Inserting Data Into A SQL Express Database

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

Inserting Data Into Database Field SmallMoney

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

Problems Inserting And Updating Data Into Sql Database

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

Problem Inserting Data To A Database Using ADODB

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

Lock On Table While Inserting Data In Database

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

Exporting/Importing Database Data (Sql Server 2005 To Sql Server 2005)

Nov 5, 2007

I'm really new to the whole database deal (as well as VB.net) - specifically with the capabilities surrounding VB and SQL Server 2005. My question is open to any recommendations...

What I have is an application that a user uses to create 'new' products. They are presented a form to enter the information regarding the product they wish to create. They enter the details of the product and also locate an image that represents the product, too. Currently, this application saves the product information (including binary image data) into a SQL Server 2005 Express Edition database. This application and database reside on a client pc. What I need to do is to be able save updated and newly created product data into a file of some sort. That file will make its way to a memory stick (USB) and then be transported to a 'field' machine. Quite simply, what is the best way to do this? Are there walk-throughs on this sort of thing? The target database is also SQL Server 2005. I thought I'd post this question on here to get the best design ideas... Any help would be greatly appreciated.

~javasource

View 1 Replies View Related

Working In VB.Net 2005 Inserting NULL Into A Field In Microsoft SQL Server 2005

Feb 2, 2007

I am update/inserting records threw a web form in vb.net. I need to insert 'NULL'  into my microsoft sql server database.  I am not talking about the below line of code where website is the name of my paramater.  If i do that it will just place a blank into that field in the database.  If i dont enter anything into that textbox I want it to to say NULL in that field. So if I go into the actual table in the SQL Server Management Studio and look at the website field of the recored I just added or updated and did not type anything into the web site textbox it needs to say NULL.  I also tried the second line of code but that places a single quote in front and behind NULL. So the field will have the value 'NULL'.
website.value = txtwebsite.text.tostirng
 if txtwebsite.text ="" then
   website.value ="NULL"
end if
The reason why I need the NULL there is because I bind the website filed to a hyperlink template in a gridview.  The actual text of the hyperlink is bound to PAYER which is a name of a insurance payer but the navigateto is bound to the website field.  If i do not enter any data into the website field and it stays as NULL, then when my gridview is loaded, payers that dont have a website will not be underlined and user wont have the option to click on them since there is no value for the navigateto.  But if i use my form to update/add a payer and leave the website textbox blank in puts a blank into that field in my database and when it loads that new row into the gridview the PAYER is underlined and u can click on it but it will just take u to the web site is unavailable page.  So is there anyway to actaull have NULL placed into a filed and not just blank space

View 3 Replies View Related







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