Who know how to let winForms C# access SQL database through internet.

thanks all~~~

let said I got a record

OrderFormNo=123 and CashBillNo='ABC'

if I want insert same order, then record must have OrderFormNo=123 and CashBillNo='ABC'
if the OrderFormNo = 456 and CashBillNo='ABC', it will pop out message and disallow to insert.

I'm using Microsoft Access, using Sql query to insert.
My purpose is want detect if CashBillNo already exist in database, but the OrderFormNo is different, will pop out message box and no perform insert command.

my record got OrderFormNo and CashBillNo.(one to one insert)
if 1st record OrderFormNo is 123 and CashBillNo is ABC, if 2nd record also same OrderFormNo, the CashBill must be same.
As a result, I want detect if got same OrderFormNo in database but different CashBillNo, will not insert to database.

I got a datagridview, record daily water meter.
so I want minus today record with yesterday 1 and get using how many meter of water.
Refer attachment will clearly to know. untitled16

I got a datgridview. I add 1 more column to get difference of Meter 2 and meter 1.

private void Loads()
        {
            ConnectionStringSettings conSettings = ConfigurationManager.ConnectionStrings["MyDBConnectionString"];
            string name = conSettings.ProviderName;
            string providerName = conSettings.ProviderName;
            string ConnectionString = conSettings.ConnectionString;

            string sql = "SELECT * FROM WaterRecord Order by RecordID DESC";

            SqlConnection connection = new SqlConnection(ConnectionString);
            connection.Open();
            sCommand = new SqlCommand(sql, connection);

            sAdapter = new SqlDataAdapter(sCommand);
            sBuilder = new SqlCommandBuilder(sAdapter);
            sDs = new DataSet();
            sAdapter.Fill(sDs, "WaterRecord");
            sTable = sDs.Tables["WaterRecord"];
            connection.Close();

            dataGridView1.DataSource = sDs.Tables["WaterRecord"];
            dataGridView1.ReadOnly = true;

            dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;

            txtNote.Text = "";
        }

use datareader to retrieve data from database . like
Select * from (Table) where price >= 500 and price <=1000

I want pop out a confirm message box like
Response.Write("<Script>confirm('Are you sure???');</Script>");

But I want control if Ok then do wat else do wat.

protected void btnIntOrder_Click(object sender, EventArgs e)
    {

        OleDbConnection conAuthor;
        SqlConnection conAuthors;

        conAuthor = new OleDbConnection(SideOrderConn);
        conAuthors = new SqlConnection(WMConn);

        OleDbCommand cmdInsert, cmdCheckID;
        OleDbDataReader dtrCheckID;
        SqlCommand cmdUpdate;

        conAuthor.Open();
        conAuthors.Open();

        foreach (GridDataItem selectItem in rgCustPO.SelectedItems)
        {
            //GridDataItem selectItem = (GridDataItem)rgCustPO.SelectedItems[0];
            string Customer = selectItem["cust_name"].Text;
            string Brand = selectItem["brand"].Text;
            string Model = selectItem["model"].Text;
            double WidthS = Convert.ToDouble(selectItem["width"].Text);
            string Width = string.Format("{0:0.##}", WidthS);
            double LengthS = Convert.ToDouble(selectItem["length"].Text);
            string Length = string.Format("{0:0.##}", LengthS);
            double ThicknessS = Convert.ToDouble(selectItem["thickness"].Text);
            string Thickness = string.Format("{0:0.##}", ThicknessS);
            string Sizes = Width + " " + selectItem["width_unit"].Text + " x " + Length + " " + selectItem["length_unit"].Text + " x " + Thickness + " " + selectItem["thickness_unit"].Text;
            string PO_NO = selectItem["cust_pono"].Text;
            string Item_NO = selectItem["cust_poitemno"].Text;
            string Qty = selectItem["qty"].Text;
            string Unit = selectItem["qty_unit"].Text;
            string Dely_Date = selectItem["delivery_date"].Text;

            SideOrderConn = "Insert Into [SideOrder](Cust, PO_NO,  Item_NO, Date_Of_Order, Dept, Brand1, Size1, Qty, Unit,Assembly,Padding,Dely_Date,Status,Remarks,Department)Values(@Cust, @PO_NO,  @Item_NO, @Date_Of_Order, @Dept, @Brand1, @Size1, @Qty, @Unit,@Assembly,@Padding,@Dely_Date,@Status,@Remarks,@Department)";
            string strUpdate = "Update cust_poitem set po_status=@po_status where cust_pono=@cust_pono and cust_poitemno=@cust_poitemno";
            string strChechID = "select * from [Setting] where [Cust1]= '" + Customer + "' and [Brand]='" + Brand + "' and [Model]='" + Model + "' and [Size]='" + Sizes + "'";

            cmdCheckID = new OleDbCommand(strChechID, conAuthor);
            cmdInsert = new OleDbCommand(SideOrderConn, conAuthor);
            cmdUpdate = new SqlCommand(strUpdate, conAuthors);

            dtrCheckID = cmdCheckID.ExecuteReader();

            if (dtrCheckID.HasRows == true)
            {
                while (dtrCheckID.Read())
                {
                    string Dept = Convert.ToString(dtrCheckID["Dept"]);
                    string Brand1 = Convert.ToString(dtrCheckID["Brand1"]);
                    string Size1 = Convert.ToString(dtrCheckID["Size1"]);
                    string QtyS = Convert.ToString(dtrCheckID["Qty"]);
                    string UnitS = Convert.ToString(dtrCheckID["Unit"]);

                    double totalQty = (Convert.ToDouble(QtyS) * Convert.ToDouble(Qty));

                    cmdInsert.Parameters.AddWithValue("@Cust", Customer);
                    cmdInsert.Parameters.AddWithValue("@PO_NO", PO_NO);
                    cmdInsert.Parameters.AddWithValue("@Item_NO", Item_NO); ...

I have a gridview contain 3 record, when I use OleDbDataReader to verify the record is match with data in other Table in access.

My problem is if the record is no match, I will end process and do not perform insert. But when 1st record is match and 2nd no match, the 1st will insert to database and 2nd will stop.But I is either 1 record no match will stop and no record will insert to database.

C# program

When I select few records from datagridview and insert into access database. First selected record will last insert into database and last selected records will insert first.

I got give a number to each record. For example, I got 3 items. When I select this 3 items and insert to database, the last item will get number 1 and first item will get number 3.

How can I let first item get number 1, second item get number 2 and so on.

I want display 1 record become 4 record for print label purpose. For Example, Model A quantity is 100 pcs, every package only can 25pcs. so I want display as attach picture in datagridview in C#.

quantity records is based on Quantity / ItemPerPackage.

I want user key in CAPITAL LETTER in combobox and textbox

thanks it work for me. but now I want read database and get highest number and then +1 for next number.

I want generate a auto number in asp.net which must start as Cust. For example Cust/00001

for example, i have 2 records, this 2 record have same [AutoNumber], if [AutoNumber] is same, then highlight row.

I want detect duplicate row for certain column in datagridview and highlight the row.

I wan develop a program which is detect database got new record, then it will pop out message such as MSN login & logout status at right hand side below.

or detect record status and pop out message box to tell user

I want develop a asp.net C# web application. I put it in IIS. Now I want make some security function in address bar. For example, I don't want let user skip login page and key in path directly.

I want get smaller number of Qty from select record in datagridview. after that insert to another Table.

For Example, datagridview A got 5 record with same PONO, when I move these record to datagridview B, they will become a summary record and 5 records become 1 record. like picture below. When record display in datagridview B, the Qyt must be smaller 1.

[CODE]private void timerFactoryOld_Tick(object sender, EventArgs e)
{
SqlCommand cmdCheckID1;
SqlDataReader dtrCheckID1;

        foreach (DataGridViewRow r in dataGridView1.SelectedRows)
        {

            string PONO = r.Cells[1].Value.ToString();
            string DeliveryDate = r.Cells[2].Value.ToString();
            string Customer = r.Cells[3].Value.ToString();
            string Name = r.Cells[4].Value.ToString();
            string Item = r.Cells[5].Value.ToString();
            string Model = r.Cells[6].Value.ToString();
            string FGrade = r.Cells[7].Value.ToString();
            string Thk = r.Cells[8].Value.ToString();
            string T_Unit = r.Cells[9].Value.ToString();
            string Width = r.Cells[10].Value.ToString();
            string W_Unit = r.Cells[11].Value.ToString();
            string Length = r.Cells[12].Value.ToString();
            string L_Unit = r.Cells[13].Value.ToString();
            string Qty = r.Cells[14].Value.ToString();
            string StockIn = r.Cells[15].Value.ToString();
            string Shortage = r.Cells[16].Value.ToString();
            string ItemPerPackage = r.Cells[17].Value.ToString();
            string Package = r.Cells[18].Value.ToString();
            string Remain = r.Cells[19].Value.ToString();
            bool InternalOrder = Convert.ToBoolean(r.Cells[20].Value.ToString());
            bool Loading = Convert.ToBoolean(r.Cells[21].Value.ToString());
            bool Finished = Convert.ToBoolean(r.Cells[0].Value.ToString());
            bool Urgent = Convert.ToBoolean(r.Cells[22].Value.ToString());
            string ReceivedDate = r.Cells[23].Value.ToString();
            string Remark = r.Cells[24].Value.ToString();
            string Zone = r.Cells[25].Value.ToString();

            //Connectt to Database
            ConnectionStringSettings conSettings = ConfigurationManager.ConnectionStrings["MyDBConnectionString"];
            string name = conSettings.ProviderName;
            string providerName = conSettings.ProviderName;
            string ConnectionString = conSettings.ConnectionString;

            //Code Insert Both values into database table
            SqlConnection con = new SqlConnection(ConnectionString);

            con.Open();

            string strChechID1 = "select * from Old where PO_NO='" + PONO + "'";
            cmdCheckID1 = new SqlCommand(strChechID1, con);
            dtrCheckID1 = cmdCheckID1.ExecuteReader();

            SqlCommand comm = new SqlCommand("insert into Old values(@PO_NO,@Model,@Qty,@Remark,@Delivery_Date,@Total_Item)", con);

            Int32 selectedRowCount = dataGridView1.Rows.GetRowCount(DataGridViewElementStates.Selected); ...

I want to set text file location in app.config

Something like these(below code is use to store database location)

[CODE]<?xml version="1.0"?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="MyDBConnectionString" connectionString="Data Source=LIANPIAU\SQLEXPRESS;Initial Catalog=DiningChair;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="MyDBConnectionString_PO" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="\Shlim\wansern prog\PODiningA.mdb""
providerName="System.Data.OleDb" />
<add name="MyDBConnectionString_Loading" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="C:\LorryBook.mdb""
providerName="System.Data.OleDb" />
<add name="MyDBConnectionString_ReportSystem" connectionString="Data Source=SHLIM;Initial Catalog=Report;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="DiningMould" connectionString="Data Source=SHLIM;Initial Catalog=DiningMould;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="MyDBConnectionString_Access" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="\Wdsharespace\Wansern_System\Wansern_Foam\Instyle Sofa\Instyle_Sofa.mdb""
providerName="System.Data.OleDb" />
<add name="EventLog" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="\Wdsharespace\Wansern_System\Wansern_Foam\Instyle Sofa\Event_Log\Log.txt""
providerName="System.Data.OleDb" />
</connectionStrings>
<system.windows.forms jitDebugging="true"/>

</configuration>[/CODE]

so that I call the location to use
[CODE]<?xml version="1.0"?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="MyDBConnectionString" connectionString="Data Source=LIANPIAU\SQLEXPRESS;Initial Catalog=DiningChair;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="MyDBConnectionString_PO" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="\Shlim\wansern prog\PODiningA.mdb""
providerName="System.Data.OleDb" />
<add name="MyDBConnectionString_Loading" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="C:\LorryBook.mdb""
providerName="System.Data.OleDb" />
<add name="MyDBConnectionString_ReportSystem" connectionString="Data Source=SHLIM;Initial Catalog=Report;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="DiningMould" connectionString="Data Source=SHLIM;Initial Catalog=DiningMould;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="MyDBConnectionString_Access" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="\Wdsharespace\Wansern_System\Wansern_Foam\Instyle Sofa\Instyle_Sofa.mdb""
providerName="System.Data.OleDb" />
<add name="EventLog" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="\Wdsharespace\Wansern_System\Wansern_Foam\Instyle Sofa\Event_Log\Log.txt""
providerName="System.Data.OleDb" />
</connectionStrings>
<system.windows.forms jitDebugging="true"/>

</configuration>[/CODE]

I want store text file location because I want to use it for my log event file
[CODE]System.IO.StreamWriter writer = new System.IO.StreamWriter("\\Wdsharespace\Wansern_System\Wansern_Foam\Instyle Sofa\Event_Log\AddOrder.txt", true);
writer.Write(DateTime.Now.ToString() + " ");
writer.Write("[Add Order to PDC] ");
writer.Write("[PONO]" + txtPONO.Text + " ");
writer.Write("[Item]" + txtItemM.Text + " ");
writer.Write("[User]" + lblUserName.Text + " ");
writer.Write("[Del.Date]" + dtpDeliveryDate.Value + " ");
writer.Write("[Customer]" + cboCustomer.Text + " ");
writer.Write("[Model]" + cboModel.Text + " ");
writer.Write("[FGrade]" + cboFGrade.Text + " ");
writer.Write("[Size]" + cboThk.Text + cboT_Unit.Text + " X ");
writer.Write(cboSize.Text + cboW_Unit.Text + " X ");
writer.Write(cboLength.Text + cboL_Unit.Text + " ");
writer.WriteLine("[Qty]" + txtQty.Value);

                writer.Close(); ...

Thanks. It work for me. but if I wan always add new record at the above of old record. How can I do??

I want write a text file event log. but when i want add second record(from datagridview) to text file, it will replace 1 record.

[CODE]private void btnAddGoods_Click(object sender, EventArgs e)
{
SqlCommand cmdCheckID;
SqlDataReader dtrCheckID;

        foreach (DataGridViewRow r in dataGridView1.SelectedRows)
        {

            string PONO = r.Cells[0].Value.ToString();
            string DeliveryDate = r.Cells[1].Value.ToString();
            string Customer = r.Cells[2].Value.ToString();
            string Name = r.Cells[3].Value.ToString();
            string Item = r.Cells[4].Value.ToString();
            string Model = r.Cells[5].Value.ToString();
            string FGrade = r.Cells[6].Value.ToString();
            string Thk = r.Cells[7].Value.ToString();
            string T_Unit = r.Cells[8].Value.ToString();
            string Width = r.Cells[9].Value.ToString();
            string W_Unit = r.Cells[10].Value.ToString();
            string Length = r.Cells[11].Value.ToString();
            string L_Unit = r.Cells[12].Value.ToString();
            string Qty = r.Cells[13].Value.ToString();
            string StockIn = r.Cells[14].Value.ToString();
            string Shortage = r.Cells[15].Value.ToString();
            string ItemPerPackage = r.Cells[16].Value.ToString();
            string Package = r.Cells[17].Value.ToString();
            string Remain = r.Cells[18].Value.ToString();
            bool InternalOrder = Convert.ToBoolean(r.Cells[19].Value.ToString());
            bool Loading = Convert.ToBoolean(r.Cells[20].Value.ToString());
            bool Finished = Convert.ToBoolean(r.Cells[21].Value.ToString());
            bool Urgent = Convert.ToBoolean(r.Cells[22].Value.ToString());
            string ReceivedDate = r.Cells[23].Value.ToString();
            string Remark = r.Cells[24].Value.ToString();

            //Connectt to Database
            ConnectionStringSettings conSettings = ConfigurationManager.ConnectionStrings["MyDBConnectionString"];
            string name = conSettings.ProviderName;
            string providerName = conSettings.ProviderName;
            string ConnectionString = conSettings.ConnectionString;

            //Code Insert Both values into database table
            SqlConnection con = new SqlConnection(ConnectionString);

            con.Open();

            string strChechID = "select * from PDC_FG where PONO='" + PONO + "' and Customer='" + Customer + "' and Model='" + Model + "' and FGrade='" + FGrade + "'and Thk='" + Thk + "'and Width='" + Width + "' and Length ='" + Length + "' and Item='" + Item + "'";
            cmdCheckID = new SqlCommand(strChechID, con);
            dtrCheckID = cmdCheckID.ExecuteReader();

            SqlCommand comm = new SqlCommand("insert into PDC_FG values(@PONO,@DeliveryDate,@Customer,@Name,@Item,@Model,@FGrade,@Thk,@T_Unit,@Width,@W_Unit,@Length,@L_Unit,@Qty,@StockIn,@Shortage,@ItemPerPackage,@Package,@Remain,@InternalOrder,@Loading,@Finished,@Urgent,@ReceivedDate,@Remark)", con);
            SqlCommand comm1 = new SqlCommand("Delete From ...

I develop a cash bill system. when a salesman have more than 2 order no paid, then cannot insert order. (1 order can contain many item, if in database can have same order no. but different product).

database field : - name(text), paid(boolean),orderNo(text).and so on ...

I want let exe detect new version of exe. Then it will update itself. my program is develop in Microsoft Visual Studio 2008 C# windows form application.

please refer attach picture

Who know how to implement Mesh Topology, actually is want implement backup link. if 1 link is fail, another still can working.But I think implement in normal switch. (no in Cisco switch)

I want select rows from datagridview and insert into another Table(give the table : Label)

Now my problem is this datagridview contain columns quantity and ItemPerPackage. Quantity column is Total quantity for this item and ItemPerPackage is 1 package can contain how many quantity.

therefore, I want this 1 record insert to Label Table become multiple record. eg. Quantity is 52 and ItemPerPackage is 10. So it must has 6 records and every record quantity is 10 except last record is 2.

I do like this is want print label for paste at item.

my Insert code is like this
[CODE]SqlCommand cmdCheckID;
SqlDataReader dtrCheckID;

        foreach (DataGridViewRow r in dataGridView1.SelectedRows)
        {

            string PONO = r.Cells[0].Value.ToString();
            string DeliveryDate = r.Cells[1].Value.ToString();
            string Customer = r.Cells[2].Value.ToString();
            string Name = r.Cells[3].Value.ToString();
            string Item = r.Cells[4].Value.ToString();
            string Model = r.Cells[5].Value.ToString();
            string FGrade = r.Cells[6].Value.ToString();
            string Thk = r.Cells[7].Value.ToString();
            string T_Unit = r.Cells[8].Value.ToString();
            string Width = r.Cells[9].Value.ToString();
            string W_Unit = r.Cells[10].Value.ToString();
            string Length = r.Cells[11].Value.ToString();
            string L_Unit = r.Cells[12].Value.ToString();
            string Qty = r.Cells[13].Value.ToString();
            string StockIn = r.Cells[14].Value.ToString();
            string Shortage = r.Cells[15].Value.ToString();
            string ItemPerPackage = r.Cells[16].Value.ToString();
            string Package = r.Cells[17].Value.ToString();
            string Remain = r.Cells[18].Value.ToString();
            Boolean InternalOrder = Convert.ToBoolean(r.Cells[19].Value.ToString());
            Boolean Loading = Convert.ToBoolean(r.Cells[20].Value.ToString());
            Boolean Finished = Convert.ToBoolean(r.Cells[21].Value.ToString());
            Boolean Urgent = Convert.ToBoolean(r.Cells[22].Value.ToString());
            string ReceivedDate = r.Cells[23].Value.ToString();
            string Remark = r.Cells[24].Value.ToString();

            //Connectt to Database
            ConnectionStringSettings conSettings = ConfigurationManager.ConnectionStrings["MyDBConnectionString"];
            string name = conSettings.ProviderName;
            string providerName = conSettings.ProviderName;
            string ConnectionString = conSettings.ConnectionString;

            SqlConnection con = new SqlConnection(ConnectionString);

            con.Open();

            string strChechID = "select * from Label where PONO='" + PONO + "' and Model='" ...

I want compare 2 datagridview table for calculation purpose. This is because this 2 table is come from different database. 1 is access and 1 is sql server. therefore I cannot join table.So I have 3 datagridview table to display data. I'm want datagridview3 ItemPerPack Column * datagridview1 Qty when they add to next table. datagridview2 is for select item purpose.when user key in PONO,qty and select item in datagridview2. then this detail will add into datagridview1

[CODE]//display data into datagridview3 from Microsoft SQl server 2008.
//This table column are FGrade,Thk,Width,Length,ItemPerPack

private void Form1_Load(object sender, EventArgs e)
{

        ConnectionStringSettings conSettings = ConfigurationManager.ConnectionStrings["MyDBConnectionString_ReportSystem"];
        string name = conSettings.ProviderName;
        string providerName = conSettings.ProviderName;
        string ConnectionString = conSettings.ConnectionString;

        string sql = "SELECT * FROM LabelQtyDining";
        SqlConnection connection = new SqlConnection(ConnectionString);
        connection.Open();
        sCommand = new SqlCommand(sql, connection);
        sAdapter = new SqlDataAdapter(sCommand);
        sBuilder = new SqlCommandBuilder(sAdapter);
        sDs = new DataSet();
        sAdapter.Fill(sDs, "LabelQtyDining");
        sTable = sDs.Tables["LabelQtyDining"];
        connection.Close();
        dataGridView3.DataSource = sDs.Tables["LabelQtyDining"];
        dataGridView3.ReadOnly = true;
        dataGridView3.Columns[5].HeaderText = "Item per Pack";

        dataGridView3.SelectionMode = DataGridViewSelectionMode.FullRowSelect;

    }

//display data into datagridview2 from Access Database (Product list)
//This table column are Model,FGrade,Thk,T_Unit,Width,W_Unit,Length,L_Unit,Qty
private void Product()
{
ConnectionStringSettings conSettings = ConfigurationManager.ConnectionStrings["MyDBConnectionString"];
string name = conSettings.ProviderName;
string providerName = conSettings.ProviderName;
string ConnectionString = conSettings.ConnectionString;

        string sql = "SELECT * From Product Where Cust='" + cboCustomer.Text + "' ORDER BY Model,FGrade";
        OleDbConnection connection = new OleDbConnection(ConnectionString);
        connection.Open();
        sCommand = new OleDbCommand(sql, connection);
        sAdapter = new OleDbDataAdapter(sCommand);
        sBuilder = new OleDbCommandBuilder(sAdapter);
        sDs = new DataSet();
        sAdapter.Fill(sDs, "Product");
        sTable = sDs.Tables["Product"];
        connection.Close();
        dataGridView2.DataSource = sDs.Tables["Product"];
        dataGridView2.ReadOnly = true; ...