16,016,759 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Aydotcom (Top 9 by date)
Aydotcom
18-Dec-17 9:52am
View
Hello Simon,
I studied debugger and practiced as suggested and i also copy and paste but i could still not detect the error. Please help me further
Aydotcom
4-Dec-17 9:30am
View
Hi Arham, am thankful. The suggestion works
Aydotcom
14-Nov-17 11:04am
View
Hi guys, the problem solved after following the guide but another error came up "No Record". kindly help me further
Aydotcom
2-Nov-17 9:29am
View
Thanks for the help. However, after amending as recommended and correcting all popped-up errors, I now received "Updated" but no row updated in the table. Kindly help me further
Aydotcom
20-Oct-17 13:31pm
View
Thank you for this assistance, however, another error came up "An unhandled exception of type 'System.ArgumentException' occurred in System.Data.dll
Additional information: No mapping exists from object type System.Windows.Forms.PictureBox to a known managed provider native type" Please help further
Aydotcom
6-Oct-17 13:32pm
View
Thanks for the assistance . After modifying with the following code, i receive the error " An unhandled exception of type 'System.ArgumentException' occurred in System.Data.dll
Additional information: Format of the initialization string does not conform to specification starting at index 0.". Please help
namespace FHAMortgageBank
{
public partial class Add_Employee : Form
{
// can use connection from the web configuration which is far better than this ...
// can give the simple string
//string constring = "path" or Webconfiguration add..;
string constring = "path";
SqlConnection con = new SqlConnection("Data Source=AKINTOMIDE-HP\\SQLEXPRESS;Initial Catalog=fham;Integrated Security=True");
SqlCommand cmd;
SqlDataAdapter adapt;
private DataViewManager dviewmanager;
//ID variable used in Updating and Deleting Record
int SN = 0;
public Add_Employee()
{
InitializeComponent();
ClearData();// Method
FillBank();
FillStatus();
FillPenAdmin();
FillYear();
FillGrade();
FillDpt();
//New_Rec();
//label1.Text = strTextBox;
//listPB = new List<picturebox>();
//chkBoxList = new List<checkbox>();
////Declare the connection string
//str = "Data Source=MYPC;Initial Catalog=myDB;Integrated Security=True";
////Initialize the list
//listPB.Add(pictureBox1);
//listPB.Add(pictureBox2);
//listPB.Add(pictureBox3);
//listPB.Add(pictureBox4);
//chkBoxList.Add(chkpicture1);
//chkBoxList.Add(chkpicture2);
//chkBoxList.Add(chkpicture3);
//chkBoxList.Add(chkpicture4);
// Get Database Connection
//_conn = new SqlConnection("data source=XEON;" +
// "initial catalog=Northwind;" +
// "user id=sa;password=manager;");
}
private void frmMain_Enter(object sender, EventArgs e)
{
}
//public frmMain()
//{
// InitializeComponent();
// DisplayData();
//}
private void BntSave_Click(object sender, EventArgs e)
{
using (SqlConnection con = new SqlConnection(constring)) ;
{
// can also take the using for sqlcommand inside of it..rest is same as you did
if (this.txteid.Text != "" && txtStaf.Text != "")
{
con.Open();
cmd = new SqlCommand("insert into master (eid,mon,yr,dat,staf,adrs,coy,loc,dpt,grd,datead,datemod,bsal,tran,hous,lunc,uti,furn,harz,educ,housM,dres,risk,veh,driv,dome,pfs,nhf,nhfs,nhis,oded,otherpay,housU,dressU,staffM,Thrift,accno,bank,email,penadmin,pennum,status,dupfront,picstaffpix) values(@eid,@mon,@yr,@dat,@staf,@adrs,@coy,@loc,@dpt,@grd,@datead,@datemod,@bsal,@tran,@hous,@lunc,@uti,@furn,@harz,@educ,@housM,@dres,@risk,@veh,@driv,@dome,@pfs,@nhf,@nhfs,@nhis,@oded,@otherpay,@housU,@dressU,@staffM,@Thrift,@accno,@bank,@email,@penadmin,@pennum,@status,@dupfront,@picstaffpix)", con);
cmd.Parameters.AddWithValue("@eid", txteid.Text);
cmd.Parameters.AddWithValue("@mon", cmbMon.Text);
cmd.Parameters.AddWithValue("@yr", cmbYr.Text);
cmd.Parameters.AddWithValue("@dat", SqlDbType.Date);
cmd.Parameters.AddWithValue("@datead", SqlDbType.DateTime);
cmd.Parameters.AddWithValue("@datemod", SqlDbType.DateTime);
cmd.Parameters.AddWithValue("@staf", txtStaf.Text);
cmd.Parameters.AddWithValue("@adrs", txtAdrs);
cmd.Parameters.AddWithValue("@coy", txtC
Aydotcom
5-Oct-17 14:39pm
View
Thanks for the assistance, however, i still received an error "An unhandled exception of type 'System.ArgumentException' occurred in System.Data.dll
Additional information: No mapping exists from object type System.Windows.Forms.TextBox to a known managed provider native type"
Please help
Aydotcom
14-Apr-17 17:06pm
View
Hi,
After studying the articles in the post i practiced using the following codes and also created a database sample as well as a table called tbl_records but i encountered an error " A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
Additional information: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)" during compilation . Can somebody help me please?
using System;
using System.Data;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace InsertUpdateDeleteDemo
{
public partial class frmMain : Form
{
SqlConnection con = new SqlConnection("Data Source=akintomide-pc;Initial Catalog=Sample;Integrated Security=true;");
SqlCommand cmd;
SqlDataAdapter adapt;
//ID variable used in Updating and Deleting Record
int ID = 0;
public frmMain()
{
InitializeComponent();
DisplayData();
}
private void btn_Delete_Click(object sender, EventArgs e)
{
if (ID != 0)
{
cmd = new SqlCommand("delete tbl_Records where ID=@id", con);
con.Open();
cmd.Parameters.AddWithValue("@id", ID);
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Record Deleted Successfully!");
DisplayData();
ClearData();
}
else
{
MessageBox.Show("Please Select Record to Delete");
}
}
private void btn_Insert_Click_1(object sender, EventArgs e)
{
if (txt_Name.Text != "" && txt_State.Text != "")
{
cmd = new SqlCommand("insert into tbl_Records(Name,State) values(@name,@state)", con);
con.Open();
cmd.Parameters.AddWithValue("@name", txt_Name.Text);
cmd.Parameters.AddWithValue("@state", txt_State.Text);
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Record Inserted Successfully");
DisplayData();
ClearData();
}
else
{
MessageBox.Show("Please Provide Details!");
}
}
//Display Data in DataGridView
private void DisplayData()
{
con.Open();
DataTable dt = new DataTable();
adapt = new SqlDataAdapter("select * from tbl_Records", con);
adapt.Fill(dt);
dataGridView1.DataSource = dt;
con.Close();
}
//Clear Data
private void ClearData()
{
txt_Name.Text = "";
txt_State.Text = "";
ID = 0;
}
//Update Record
private void btn_Update_Click_1(object sender, EventArgs e)
{
if (txt_Name.Text != "" && txt_State.Text != "")
{
cmd = new SqlCommand("update tbl_Records set Name=@name,State=@state where ID=@id", con);
con.Open();
cmd.Parameters.AddWithValue("@id", ID);
cmd.Parameters.AddWithValue("@name", txt_Name.Text);
cmd.Parameters.AddWithValue("@state", txt_State.Text);
cmd.ExecuteNonQuery();
MessageBox.Show("Record Updated Successfully");
con.Close();
DisplayData();
ClearData();
}
else
{
MessageBox.Show("Please Select Record to Update");
}
}
private void dataGridView1_CellContentClick(obj
Aydotcom
12-Apr-17 13:34pm
View
The solutions really help me to kick start, thanks in millions.
Show More