Code:
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;
using System.Configuration;
namespace WindowsFormsApplication1
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
SqlConnection ABC = new SqlConnection(@"Data Source=C:\Users\Somline\Documents\Visual Studio 2008\Projects\PROGRAMA\WindowsFormsApplication1\Database1.sdf;Persist Security Info=True");
SqlCommand command = new SqlCommand();
SqlDataReader dataRead;
private void eMPRESASBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
this.Validate();
this.eMPRESASBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.cONTATOS);
}
private void Form3_Load(object sender, EventArgs e)
{
command.Connection = ABC;
this.eMPRESASTableAdapter.Fill(this.cONTATOS.EMPRESAS);
}
private void tELEFONELabel_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
ABC.Open();
command.CommandText="insert into EMPRESAS(NOME EMPRESA,TELEFONE,ENDERE�O,BAIRRO,CONTATOS) Values('"+nOME_EMPRESATextBox.Text+"','"+tELEFONETextBox.Text+"','"+eNDERE�OTextBox.Text+"','"+bAIRROTextBox.Text+"','"+cONTATOSTextBox.Text+"')";
command.ExecuteNonQuery();
ABC.Close();
MessageBox.Show("EMPRESA CADASTRADA COM SUCESSO...!");
nOME_EMPRESATextBox.Clear();
tELEFONETextBox.Clear();
eNDERE�OTextBox.Clear();
bAIRROTextBox.Clear();
cONTATOSTextBox.Clear();
}
private void eMPRESASDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void bAIRROLabel_Click(object sender, EventArgs e)
{
}
private void eMPRESASBindingNavigator_RefreshItems(object sender, EventArgs e)
{
}
}
}
Appears
Network error or specific to the instance when connecting 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: SQL Network Interfaces , error : 26 - Error Locating Server / Instance Specified )
and
Warning 1 The field 'WindowsFormsApplication1.Form1.dataRead' is never used C:\Users\Somline\Documents\Visual Studio 2008\Projects\PROGRAMA\WindowsFormsApplication1\Fo rm1.cs 21 23 WindowsFormsApplication1
(you need an account to see links)
Code:
database string : Data Source=C:\Users\Somline\Documents\Visual Studio 2008\Projects\PROGRAMA\WindowsFormsApplication1\Database1.sdf;Persist Security Info=True
A PROGRAM A LITLE SO LIKE THIS
HTML Code:
https://www.youtube.com/watch?v=GysB6QEc04Y
for run only in my PC thanks