hi all,
i hav created a webpart for inserting a record in asp.net ,c# and deploy it in sharepoint.. my code is executing properly.. when i deploy it it asks for insert new record and wen i get the details and click insert the values are not getting stored in sql server database.. could any one point me out what s wrong in the program..i hav posted my prog below
Thanks
Sri -
using System;
-
using System.Web.UI;
-
using System.Web.UI.WebControls;
-
using System.ComponentModel;
-
using System.Data;
-
using System.Configuration;
-
using System.Web;
-
using System.Security;
-
using System.Web.Security;
-
using Microsoft.SharePoint.WebPartPages;
-
using System.Web.UI.HtmlControls;
-
using System.Data.SqlClient;
-
using System.Xml;
-
using System.Security.Permissions;
-
-
namespace dweb
-
{
-
/// <summary>
-
/// Summary description for WebCustomControl1.
-
/// </summary>
-
[DefaultProperty("Text"),
-
ToolboxData("<{0}:WebCustomControl1 runat=server></{0}:WebCustomControl1>")]
-
public class dweb:WebPart
-
{
-
-
//private string text;
-
-
[Bindable(true),
-
Category("Appearance"),
-
DefaultValue("")]
-
-
Label lid=new Label();
-
TextBox txtid=new TextBox();
-
Label lfname=new Label();
-
TextBox txtfname=new TextBox();
-
Label lname=new Label();
-
TextBox txtlname=new TextBox();
-
Label addr=new Label();
-
TextBox txtaddr=new TextBox();
-
Label email=new Label();
-
TextBox txtemail=new TextBox();
-
TextBox txtphno=new TextBox();
-
TextBox txtdesig=new TextBox();
-
TextBox txtsal=new TextBox();
-
TextBox txtqual=new TextBox();
-
TextBox txtage=new TextBox();
-
-
-
SqlConnection con;
-
-
protected override void CreateChildControls()
-
{
-
Button insert=new Button();
-
insert.Text="Insert New Record";
-
insert.ID="create";
-
Controls.Add(insert);
-
Controls.Add(new LiteralControl("<br>"));
-
insert.Click+=new EventHandler(create_Click);
-
-
EnsureChildControls();
-
}
-
-
private void create_Click(object sender, EventArgs e)
-
{
-
-
-
lid.Text="Enter ID:";
-
Controls.Add(lid);
-
Controls.Add(txtid);
-
Controls.Add(new LiteralControl("<br>"));
-
lfname.Text="First Name:";
-
Controls.Add(lfname);
-
Controls.Add(txtfname);
-
Controls.Add(new LiteralControl("<br>"));
-
lname.Text="Last Name:";
-
Controls.Add(lname);
-
-
Controls.Add(txtlname);
-
Controls.Add(new LiteralControl("<br>"));
-
-
addr.Text="Address:";
-
Controls.Add(addr);
-
-
Controls.Add(txtaddr);
-
Controls.Add(new LiteralControl("<br>"));
-
-
email.Text="Email Id:";
-
Controls.Add(email);
-
-
Controls.Add(txtemail);
-
Controls.Add(new LiteralControl("<br>"));
-
Label phno=new Label();
-
phno.Text="Phone No:";
-
Controls.Add(phno);
-
-
Controls.Add(txtphno);
-
Controls.Add(new LiteralControl("<br>"));
-
Label desig=new Label();
-
desig.Text="Designation:";
-
Controls.Add(desig);
-
-
Controls.Add(txtdesig);
-
Controls.Add(new LiteralControl("<br>"));
-
Label sal=new Label();
-
sal.Text="Salary:";
-
Controls.Add(sal);
-
-
Controls.Add(txtsal);
-
Controls.Add(new LiteralControl("<br>"));
-
Label qual=new Label();
-
qual.Text="Qualification:";
-
Controls.Add(qual);
-
-
Controls.Add(txtqual);
-
Controls.Add(new LiteralControl("<br>"));
-
Label age=new Label();
-
age.Text="Age:";
-
Controls.Add(age);
-
-
Controls.Add(txtage);
-
Controls.Add(new LiteralControl("<br>"));
-
Button btncreate=new Button();
-
btncreate.Text="INSERT";
-
btncreate.ID="insertbtn";
-
Controls.Add(btncreate);
-
btncreate.Click +=
-
new EventHandler(insertbtn_Click);
-
}
-
-
[AspNetHostingPermission(SecurityAction.Demand, Level=AspNetHostingPermissionLevel.Unrestricted)]
-
[AspNetHostingPermissionSecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Unrestricted)]
-
-
private void insertbtn_Click(objectsender,EventArgs e)
-
{
-
-
con = new SqlConnection("Data Source=WSINTRA13;Initial Catalog=pubs; User ID=Insite.user;Password=insiteslc1");
-
string cmd = "insert into emp_details(e_id,fname,lname,address,email_id,ph_no,designation,salary,qualifictn,age) values( '" + txtid.Text + " ','" + txtfname.Text + " ','" + txtlname.Text + "','" + txtaddr.Text+ "','" +txtemail.Text+ "'," +txtphno.Text+ ",'" +txtdesig.Text+ "'," +txtsal.Text+ ",'" +txtqual.Text+ "'," + txtage.Text + ")";
-
-
-
SqlCommand scmd = new SqlCommand(cmd,con);
-
scmd.CommandText=cmd;
-
con.Open();
-
scmd.ExecuteNonQuery();
-
con.Close();
-
-
}
-
-
}
-
}
-
0 1350 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: James |
last post by:
Please help - getting very desperate! Sun, 12 October 2003 05:39
I have PHPDEV 4.2.3 from Firepages.com.au as the upgrade to 4.3.0 did
not work. I also had an abortive download from PHP.NET as I could not
configure Apache myself.
The REAL problem is that PHPmyAdmin works and sees my test database
Wines....
But my PHP program does not!
|
by: ʹÃûÑï |
last post by:
ORA-03114: not connected to ORACLE && MS's Bug??
DataBase:Oracle 817
using OracleClient,net framework 1.1
I'm using ADO.Net in C# with Oracle 817.
and following is my public data access class.
using System.Data.OracleClient;
|
by: Robert Scheer |
last post by:
Hi.
My site needs to know if the user is connected before executing some
queries on my database. Actually, I have a page loaded by an Iframe
that runs every 30 seconds and updates a field on my database to tells
me the user is connected. If this field is not updated for more than
one minute I consider the user disconnected.
The problem...
|
by: ruju00 |
last post by:
I am getting an error in Login() method of the following class
FtpConnection
public class FtpConnection
{
public class FtpException : Exception
{
public FtpException(string message) : base(message){}
public FtpException(string message, Exception innerException) :
base(message,innerException){}
|
by: Developer |
last post by:
Dear Group Member,
I am sorry if I have posted this query in wrong group, but since this
is connected with ASPO.NET2.0, thought of posting here.
I am doing a very simple program where I am inserting Grid control, SQL
datasource control.
I am attaching the default Northwind database to this Sql Datasource
and binding this to the grid...
| |
by: bill |
last post by:
I have a database of kennels. One page lists the kennels
alphabetically by kennel name.
I have a field for kennel name and an index with kennel name as
the only field.
Some of the kennels have the word "The" as the first word in the
name and they do not want to be listed alphabetically by "The..."
Is there a way that I can request that...
|
by: christopher_board |
last post by:
Hi all. I am trying to write a php page which connects to a MySQL
Database which is supposed to get the results from a table within a
database and display the results in a table.
Below is the code that I am using:
<?php
function connectDatabase() {
$dbhost = 'localhost';
$dbuser = 'root';
|
by: odrap |
last post by:
I wrote a ADO.NET ( VB.NET language) database application with the data database itself located on a SQL SERVER 2005 Express on my desktop.
The application database is on my laptop. My laptop as well as my desktop are connected to the internet. (cable -Telenet )
I have heard that the provider regulary change my IP address,and that's precisely...
|
by: rpupkin77 |
last post by:
Hey,
How does one going about their user's geographical location? Is that
even a PHP question.
For example, a site may say "Find others near Boston", but if you were
in New York, it would say "Find others in New York"
Thanks.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |