473,378 Members | 1,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Error in my asp.net application

31
Hi all,

I am a newbie to Asp.Net and currently practicing on a Job Portal Website... but encountering a problem when i try to insert my textbox and dropdownlist values into my sqlserver database called Fishingjobs.... Here is the code i am using :
Expand|Select|Wrap|Line Numbers
  1.  SqlConnection cn = newSqlConnection("Data Source=.;Initial Catalog=fishingjobs;Integrated Security=True;
  2. SqlCommand selectcmd = newSqlCommand("select * from regcompany, cn);
  3. SqlCommand insertcmd = new SqlCommand ("insert into regcompany values '" + txtuname.Text + "','" + txtpass.Text + "','" + txtemail +"','" + txtcname +"','" + RadioButtonList1.SelectedItem + "','" + txtcontactperson.Text + "','" + ddlindustrytype.SelectedItem + [/"','" + txtadd1.Text + "','" + txtadd2.Text + "','" + txtadd3.Text + "','" + ddlcountry.SelectedItem + "','" + ddlstate.SelectedItem + "','" + ddlcity.SelectedItem + "','"+txtpin.Text+"','"+txtphone.Text+"','" + txtwebsite.Text + "'", cn);
  4. SqlDataAdapter da = new SqlDataAdapter();
  5. DataSet ds = new DataSet();
  6. DataTable dt = new DataTable();
  7. cn.Open();
  8. da.SelectCommand=selectcmd;
  9. da.Fill(ds,"regcompany");
  10. dt= ds.Tables("regcompany");
  11. DataRow dr=dt.NewRow();
  12.  
  13.  
  14. dr(0)= txtuname.Text;
  15. dr(1)= txtpass.Text;
  16. dr(2)= txtemail.Text;
  17. dr(3)= txtcname.Text;
  18. dr(4)= RadioButtonList1.SelectedItem;
  19. dr(5)= txtcontactperson.Text;
  20. dr(6)= ddlindustrytype.SelectedItem;
  21. dr(7)= txtadd1.Text;
  22. dr(8)= txtadd2.Text;
  23. dr(9)= txtadd3.Text;
  24. dr(10)= ddlcountry.SelectedItem;
  25. dr(11)= ddlstate.SelectedItem;
  26. dr(12)= ddlcity.Text;
  27. dr(13)= txtpin.Text;
  28. dr(14)= txtphone.Text;
  29. dr(15)= txtwebsite.Text;
  30.  
  31. dt.Rows.Add(dr);
  32. da.InsertCommand = insertcmd;
  33. da.Update(ds, "regcompany");
  34.  
  35. cn.Close();
  36. MultiView1.SetActiveView(View2);
Jan 30 '09 #1
1 912
Frinavale
9,735 Expert Mod 8TB
Please post the error message that you're getting or indicate what is not working correctly.

Also, you shouldn't be forming your SQL insert statement using values directly inserted by the user. You should be creating this statement using parameters instead.

Check out this article for an example of what I'm talking about.
Jan 30 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: NG | last post by:
Hi, We are having DB2-V7.2 DB on AIX 5.2 machine. Recently we upgraded our system to fixpack 13 and activated activate AIX asynchronous IO function. Our DB is going to crash recovery with...
3
by: windandwaves | last post by:
Hi Gurus Does anyone know how I set the error trapping to option 2 in visual basic. I know that you can go to tools, options and then choose on unhandled errors only, but is there a VB command...
10
by: Brian Conway | last post by:
I have no idea what is going on. I have a Login screen where someone types in their login information and this populates a datagrid based off of the login. Works great in debug and test through...
6
by: Javier Cortés Cortés | last post by:
i am getting this error when i am trying to access any file(with the ext. aspx) from my remote server. the error is : Server Error in '/' Application....
3
by: Damian | last post by:
Hi everyone I'm having an issue with one of our applications. I'm getting the following error when attempting to log in to the site: Server Error in 'xxxxxxxxxxxxxxxx' Application....
4
by: tommy | last post by:
hello everbody, i write a little asp-application with forms-authentication. i copy my aspx-files with web.config to my webspace and i get the error above... i tried to set the...
7
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying....
12
by: Brett Robichaud | last post by:
Is anyone familiar with this error? I have this running just fine on my local machine but when I pushed it out to our development server I get this error. I have no idea what it is saying. Any...
0
by: Adam Getchell | last post by:
I'm attempting to write a custom Authentication module using http://www.15seconds.com/Issue/020417.htm I looked at http://support.microsoft.com/default.aspx?scid=kb;EN-US;307996, but it doesn't...
8
by: jcrouse | last post by:
I am using the following code to trap errors in a sub routine: Try Executable code Catch ex As Exception Dim strInputE As String = Application.StartupPath & "\Error.txt" Dim srE As...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.