473,387 Members | 3,750 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,387 software developers and data experts.

System.Windows.Forms.TextBox is showing in the database.

8
Hi there, Im having a problem in my sql database,
when i enter data in the textbox called "Name" and then i save it.
it shows in the database like this:-

System.Windows.Forms.TextBox, Text: Bob

How can I get rid of this

your help is greatly appreciated
Nov 5 '12 #1

✓ answered by PsychoCoder

You need to change this line:
Expand|Select|Wrap|Line Numbers
  1. sql = "insert into Registration values('" + txt_usrName + "','" + txt_pass + "','" + Txt_Name + "','" + Txt_email + "','" + txt_Rank + "')";
to this:

Expand|Select|Wrap|Line Numbers
  1. sql = "insert into Registration values('" + txt_usrName.Text + "','" + txt_pass.Text + "','" + Txt_Name.Text + "','" + Txt_email.Text + "','" + txt_Rank.Text + "')";
To get the value from the various TextBox controls you need to reference it's Text Property

4 5694
zmbd
5,501 Expert Mod 4TB
And you need to post the code that you're using to create/save the record. Please remember to format posted code using the <CODE/> button in the toolbar.
Nov 5 '12 #2
msdhh
8
I appreciate your quick response,
here is the code im using to insert the values
Expand|Select|Wrap|Line Numbers
  1.  
  2. private void Save_Click(object sender, EventArgs e)
  3.         {
  4.             try
  5.             {
  6.                 sql = "insert into Registration values('" + txt_usrName + "','" + txt_pass + "','" + Txt_Name + "','" + Txt_email + "','" + txt_Rank + "')";
  7.                 if (conn.State == ConnectionState.Closed)
  8.                 {
  9.                     conn.Open();
  10.                 }
  11.                 cmd.CommandText = sql;
  12.                 cmd.ExecuteNonQuery();
  13.                 MessageBox.Show("You have successfully registered");
  14.             }
  15.             catch (Exception exe)
  16.             {
  17.                 MessageBox.Show(exe.Message);
  18.             }
  19.             finally
  20.             {
  21.                 if (conn.State == ConnectionState.Open)
  22.                 {
  23.                     conn.Close();
  24.                 }
  25.             }
  26.  
  27.         }
  28.  
Nov 5 '12 #3
PsychoCoder
465 Expert Mod 256MB
You need to change this line:
Expand|Select|Wrap|Line Numbers
  1. sql = "insert into Registration values('" + txt_usrName + "','" + txt_pass + "','" + Txt_Name + "','" + Txt_email + "','" + txt_Rank + "')";
to this:

Expand|Select|Wrap|Line Numbers
  1. sql = "insert into Registration values('" + txt_usrName.Text + "','" + txt_pass.Text + "','" + Txt_Name.Text + "','" + Txt_email.Text + "','" + txt_Rank.Text + "')";
To get the value from the various TextBox controls you need to reference it's Text Property
Nov 5 '12 #4
msdhh
8
thanks alot, it works :)
Nov 5 '12 #5

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

Similar topics

3
by: Steven.Xu | last post by:
Hello everyone. Normally, the cell of the System.Windows.Forms.DataGrid could be inputed. How can I let the cells only show something and not be inputed?
2
by: Greg Bacchus | last post by:
Hi, I'm getting an exception that really has me stumped. It's sporadic at best, it's only happened a handful of times. This particular time it happened when the user pressed 'Alt-S' to save the...
3
by: max | last post by:
I can generate this error by NOT assigning a tableName to the view: at System.Windows.Forms.DataGrid.AddNewRow() at System.Windows.Forms.DataGridAddNewRow.OnEdit() Is there any possibility of...
4
by: Bilo | last post by:
I have a Windows Forms Class MainGUI I have declared MainGUI maingui; public System.ComponentModel.Container components = new Container(); in the Class I call another class MediaDriver with...
3
by: Ivan | last post by:
Hi, how to filter out non-digit chars when user writes text to System.Windows.Forms.TextBox? Thanks, Iavmn
2
by: Raed Sawalha | last post by:
i have a windows form(Main) with listview, when click an item in listview i open other window form (Sub) which generate the selected item from parent window in as treeview items when click any item...
5
by: Richard Lionheart | last post by:
Hi All, I tried creating a C# Form using Petzold's "Programming MS Windows with C#" guidance. He recommended using the namespace System.Windows.Forms. However, VS.NET claims "the type or...
2
by: Markus Eßmayr | last post by:
Hello, I'm writing an extension class for the winforms button control using MC++. I created a class, derived from System::Windows::Forms::Button. In my class I want to extend the functionality...
3
by: Rvo | last post by:
I have a userform which contains a textbox (System.Windows.forms.textbox) with multiline set to True. This box contains a certain number of characters which reach below the bottom of the box....
2
by: Nabeel Moeen | last post by:
Hi, the foillowing line returns a null value Type.GetType("System.Windows.Forms.TextBox") why is that so ... and what should i do if i need to compare if the control is a textbox or not? ...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
jinu1996
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...

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.