Click here to Skip to main content
15,900,378 members
Home / Discussions / C#
   

C#

 
Questionreplacing new lines and tab spacing with a single space Pin
mist_psycho20-Apr-09 4:08
mist_psycho20-Apr-09 4:08 
AnswerRe: replacing new lines and tab spacing with a single space [modified] Pin
agent00zelda20-Apr-09 4:43
agent00zelda20-Apr-09 4:43 
AnswerRe: replacing new lines and tab spacing with a single space Pin
riced20-Apr-09 4:51
riced20-Apr-09 4:51 
GeneralRe: replacing new lines and tab spacing with a single space Pin
mist_psycho20-Apr-09 6:12
mist_psycho20-Apr-09 6:12 
GeneralRe: replacing new lines and tab spacing with a single space Pin
OriginalGriff20-Apr-09 6:32
mveOriginalGriff20-Apr-09 6:32 
GeneralRe: replacing new lines and tab spacing with a single space Pin
riced20-Apr-09 7:16
riced20-Apr-09 7:16 
AnswerRe: replacing new lines and tab spacing with a single space Pin
PIEBALDconsult20-Apr-09 14:04
mvePIEBALDconsult20-Apr-09 14:04 
Questioncombobox type mismatch Pin
fecaloid monster20-Apr-09 3:51
fecaloid monster20-Apr-09 3:51 
Here is my combobox which gets values from database:

da2.TableMappings.Add("Table", "SubjectTitle");
da2.Fill(ds2);
this.dviewmanager = ds2.DefaultViewManager;
this.comboBox1.DataSource = this.dviewmanager;
this.comboBox1.DisplayMember = "SubjectTitle.Title";
this.comboBox1.ValueMember = "SubjectTitle.ID";


When I want to insert some data to database with value from combobox everything is perfect.
string insertQuery = "INSERT INTO Lection (ID_Subject, title, body) values ('" + comboBox1.SelectedValue + "','" + textBox3.Text + "','" + textBox4.Text + "')";
OleDbCommand cmd = new OleDbCommand();
cmd.CommandText = insertQuery;
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();


But when I want to select data with combobox in query I get Type mismatch error
leccom = new OleDbCommand("SELECT * FROM Lection WHERE ID_Subject ='" + comboBox1.SelectedValue + "'", leccon);
lecadapter = new OleDbDataAdapter();
lecadapter.SelectCommand = leccom;
lectable = new DataTable();
lecadapter.Fill(lectable);
textBox3.DataBindings.Add("Text", lectable, "Title");
textBox4.DataBindings.Add("Text", lectable, "Body");
lecmanager = (CurrencyManager)this.BindingContext[lectable];


ID_Subject field in database is numeric. I tried to convert combobox to an integer, but it didn't work or maybe I did it wrong. Why is this SELECT query doesn't work? Thanks in advance for any help!
AnswerRe: combobox type mismatch Pin
N a v a n e e t h20-Apr-09 4:19
N a v a n e e t h20-Apr-09 4:19 
GeneralRe: combobox type mismatch Pin
fecaloid monster20-Apr-09 5:10
fecaloid monster20-Apr-09 5:10 
QuestionData Modeler Pin
Muhammad Nauman Yousuf20-Apr-09 3:31
Muhammad Nauman Yousuf20-Apr-09 3:31 
AnswerRe: Data Modeler Pin
Nagy Vilmos20-Apr-09 3:42
professionalNagy Vilmos20-Apr-09 3:42 
QuestionSystem.Mangement.ManagementObject is not working properly in a WinForms application. Pin
darthBug20-Apr-09 3:25
darthBug20-Apr-09 3:25 
AnswerRe: System.Mangement.ManagementObject is not working properly in a WinForms application. Pin
DaveyM6920-Apr-09 3:34
professionalDaveyM6920-Apr-09 3:34 
GeneralRe: System.Mangement.ManagementObject is not working properly in a WinForms application. Pin
darthBug20-Apr-09 4:04
darthBug20-Apr-09 4:04 
GeneralRe: System.Mangement.ManagementObject is not working properly in a WinForms application. Pin
DaveyM6920-Apr-09 6:05
professionalDaveyM6920-Apr-09 6:05 
GeneralRe: System.Mangement.ManagementObject is not working properly in a WinForms application. Pin
darthBug21-Apr-09 3:30
darthBug21-Apr-09 3:30 
QuestionOnline help code Pin
Member 437447420-Apr-09 3:20
Member 437447420-Apr-09 3:20 
AnswerRe: Online help code Pin
SeMartens20-Apr-09 3:29
SeMartens20-Apr-09 3:29 
AnswerRe: Online help code Pin
King Julien20-Apr-09 3:30
King Julien20-Apr-09 3:30 
RantRe: Online help code Pin
Nagy Vilmos20-Apr-09 3:43
professionalNagy Vilmos20-Apr-09 3:43 
AnswerRe: Online help code Pin
Mycroft Holmes20-Apr-09 14:40
professionalMycroft Holmes20-Apr-09 14:40 
QuestionKEYBOARD DRIVER IN C# Pin
svt gdwl20-Apr-09 2:21
svt gdwl20-Apr-09 2:21 
AnswerRe: KEYBOARD DRIVER IN C# Pin
Vikram A Punathambekar20-Apr-09 2:59
Vikram A Punathambekar20-Apr-09 2:59 
GeneralRe: KEYBOARD DRIVER IN C# Pin
svt gdwl20-Apr-09 3:20
svt gdwl20-Apr-09 3:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.