Click here to Skip to main content
15,884,425 members
Home / Discussions / C#
   

C#

 
GeneralRe: TimeSpan equivalent for the working week Pin
hairy_hats12-Jun-09 4:49
hairy_hats12-Jun-09 4:49 
QuestionMCE Remote Controller Pin
ryan11712-Jun-09 2:46
ryan11712-Jun-09 2:46 
QuestionWMI Pin
arkiboys12-Jun-09 2:36
arkiboys12-Jun-09 2:36 
AnswerRe: WMI Pin
Dave Kreskowiak12-Jun-09 5:18
mveDave Kreskowiak12-Jun-09 5:18 
GeneralRe: WMI Pin
arkiboys12-Jun-09 8:08
arkiboys12-Jun-09 8:08 
GeneralRe: WMI Pin
Dave Kreskowiak12-Jun-09 11:15
mveDave Kreskowiak12-Jun-09 11:15 
GeneralRe: WMI [modified] Pin
arkiboys14-Jun-09 20:31
arkiboys14-Jun-09 20:31 
Questioncannot insert into database 2005 using visual c# 2008 Pin
Adekolurejo12-Jun-09 2:01
Adekolurejo12-Jun-09 2:01 
Pleas I need help on this code.

onclick on the save button this problem will prevent it from carry out the operation.
on geting to myCommand.ExecuteNonQuery();
it give me this error below.
{"Must declare the scalar variable \"@Telephone_NoParam\"."}

pls help as I dont know what to do because am new to c#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Kay_Nylon
{
public partial class COMPANY_INFO : Form
{
public COMPANY_INFO()
{
SqlConnection myConnection = new SqlConnection("user id=sa;" +
"password=admin123;server=ADEMOLAPC;" +
"Trusted_Connection=yes;" +
"database=Kay_Nylon_Db; " +
"connection timeout=30");
myConnection.Open();
//myConnection.Close();

InitializeComponent();
}

private void COMPANY_INFO_Load(object sender, EventArgs e)
{
}

private void btnSave_Click(object sender, EventArgs e)
{

SqlConnection myConnection = new SqlConnection("user id=sa;" +
"password=admin123;server=ADEMOLAPC;" +
"Trusted_Connection=yes;" +
"database=Kay_Nylon_Db; " +
"connection timeout=30");
myConnection.Open();

//try
//{

SqlCommand myCommand = new SqlCommand("INSERT INTO Company_Info(Company_Id, Company_Name, Company_Address_Line1, Company_Address_Line2, Telephone_No, Fax, Email) " +
"Values(@Company_IdParam, @Company_NameParam, @Company_Address_Line1Param, @Company_Address_Line2Param, @Telephone_NoParam, @FaxParam, @EmailParam)", myConnection);

myCommand.Parameters.AddWithValue("@Company_IdParam", txtCompanyId.Text);
myCommand.Parameters.AddWithValue("@Company_NameParam", txtCompanyName.Text);
myCommand.Parameters.AddWithValue("@Company_Address_Line1Param", txtAddress1.Text);
myCommand.Parameters.AddWithValue("@Company_Address_Line2Param", txtAddress2.Text);
myCommand.Parameters.AddWithValue("@Telephone_NoParam", txtTelephoneNo.Text);
myCommand.Parameters.AddWithValue("@FaxParam", txtFax.Text);
myCommand.Parameters.AddWithValue("@EmailParam", txtEmail.Text);


myCommand.ExecuteNonQuery();
myConnection.Close();
// }
//catch (Exception sql)
// {
// Console.WriteLine(sql.ToString());
// }
}
}
}
AnswerRe: cannot insert into database 2005 using visual c# 2008 Pin
Nagy Vilmos12-Jun-09 2:26
professionalNagy Vilmos12-Jun-09 2:26 
AnswerRe: cannot insert into database 2005 using visual c# 2008 Pin
Rob Philpott12-Jun-09 2:37
Rob Philpott12-Jun-09 2:37 
GeneralRe: cannot insert into database 2005 using visual c# 2008 Pin
PIEBALDconsult12-Jun-09 3:49
mvePIEBALDconsult12-Jun-09 3:49 
GeneralRe: cannot insert into database 2005 using visual c# 2008 Pin
Rob Philpott12-Jun-09 4:12
Rob Philpott12-Jun-09 4:12 
GeneralRe: cannot insert into database 2005 using visual c# 2008 Pin
PIEBALDconsult12-Jun-09 9:21
mvePIEBALDconsult12-Jun-09 9:21 
GeneralRe: cannot insert into database 2005 using visual c# 2008 Pin
Rob Philpott12-Jun-09 23:17
Rob Philpott12-Jun-09 23:17 
QuestionFileWather Path Error [modified][Solved] Pin
MumbleB12-Jun-09 1:58
MumbleB12-Jun-09 1:58 
AnswerRe: FileWather Path Error Pin
_AnsHUMAN_ 12-Jun-09 2:02
_AnsHUMAN_ 12-Jun-09 2:02 
GeneralRe: FileWather Path Error Pin
MumbleB12-Jun-09 2:09
MumbleB12-Jun-09 2:09 
GeneralRe: FileWather Path Error Pin
Nagy Vilmos12-Jun-09 2:17
professionalNagy Vilmos12-Jun-09 2:17 
GeneralRe: FileWather Path Error Pin
MumbleB12-Jun-09 2:28
MumbleB12-Jun-09 2:28 
GeneralRe: FileWather Path Error Pin
Nagy Vilmos12-Jun-09 2:39
professionalNagy Vilmos12-Jun-09 2:39 
GeneralRe: FileWather Path Error Pin
MumbleB12-Jun-09 2:48
MumbleB12-Jun-09 2:48 
QuestionFocus on a searched text in richtextbox Pin
rakeshs31212-Jun-09 1:55
rakeshs31212-Jun-09 1:55 
AnswerRe: Focus on a searched text in richtextbox Pin
Luc Pattyn12-Jun-09 2:34
sitebuilderLuc Pattyn12-Jun-09 2:34 
GeneralRe: Focus on a searched text in richtextbox Pin
Nagy Vilmos12-Jun-09 2:37
professionalNagy Vilmos12-Jun-09 2:37 
GeneralRe: Focus on a searched text in richtextbox Pin
Luc Pattyn12-Jun-09 3:11
sitebuilderLuc Pattyn12-Jun-09 3:11 

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.