<更改屬性>
<顯示範圍>
ChartAreas > Axes > X axis > ScaleView >
Position 起始值
Size 範圍大小
<選取範圍>
ChartAreas > CursorX >
IsUserEnabled => true
IsUserSelectionEnabled => true
2010年2月21日 星期日
2010年2月12日 星期五
2010年2月10日 星期三
C# comboBox顯示資料庫列 可對應值
string constr = "Data Source=*****;Initial Catalog=*****;Integrated Security=True";
string str_select2 = "SELECT * FROM Departments";
string str_select = str_select2 ;
SqlConnection con = new SqlConnection(constr);
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(str_select, con);
try
{
da.Fill(ds, "Departments");
DataTable datable = ds.Tables["Departments"];
comboBox1.DataSource = datable;
comboBox1.DisplayMember = "Department";
comboBox1.ValueMember = "Department_No";
}
catch (Exception ex)
{
}
2010年2月9日 星期二
EXCEL $小說明
公式內$意思是鎖住
表示全套用時候無法更改
標事前無$才會隨著套用指定位置做位移
=$F1<>$C1 <==可隨著位置改變1值
=$F$1<>$C$1 <==全鎖死
=F1<>C1 <==隨著位置改變C F 跟1的值
表示全套用時候無法更改
標事前無$才會隨著套用指定位置做位移
=$F1<>$C1 <==可隨著位置改變1值
=$F$1<>$C$1 <==全鎖死
=F1<>C1 <==隨著位置改變C F 跟1的值
2010年2月8日 星期一
2010年2月7日 星期日
C# 拆字串
依照符號拆
依照字串位置拆
char[] delimiterChars = { ' ', ',', '.', ':', '\t' };
string text = "one\ttwo three:four,five six seven";
System.Console.WriteLine("Original text: '{0}'", text);
string[] words = text.Split(delimiterChars);
System.Console.WriteLine("{0} words in text:", words.Length);
依照字串位置拆
word.Substring(1, 3) //從第二個字讀三個字
2010年2月6日 星期六
C# SQL SELECT
string constr = "Data Source=*****;Initial Catalog=*****;Integrated Security=True";
string str_select = "SELECT * FROM LAN_IP";
SqlConnection con = new SqlConnection(constr);
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(str_select, con);
da.Fill(ds,"LAN_IP");
DataTable datable = ds.Tables["LAN_IP"];
textBox1.Text= datable.Rows[1][4].ToString();
2010年2月5日 星期五
C# SQL UPDATE
SqlConnection conn;
string sqlIns;
SqlCommand cmdIns;
//-----
conn = new SqlConnection("Data Source=*****;Initial Catalog=*****;Integrated Security=True");
conn.Open();
sqlIns = "UPDATE [LAN_SNMP_TorF] SET [TorF]=@TorF WHERE [IP]=@ip";
try
{
cmdIns = new SqlCommand(sqlIns, conn);
cmdIns.Parameters.Add("@ip", "192.168.11.160");
cmdIns.Parameters.Add("@TorF", "F");
cmdIns.ExecuteNonQuery();
// Get the last inserted id.
cmdIns.Dispose();
cmdIns = null;
}
catch (Exception ex)
{
throw new Exception(ex.ToString(), ex);
}
finally
{
conn.Close();
}
C# SQL INSERT
SqlConnection conn = new SqlConnection("Data Source=*****;Initial Catalog=*****;Integrated Security=True");
conn.Open();
string sqlIns = "INSERT INTO LAN_Snmp_Value([IP], [InOctets],[OutOctets],[TotalOctets],[Time]) VALUES (@ip, @InOctets, @OutOctets,@TotalOctets,@Time)";
try
{
SqlCommand cmdIns = new SqlCommand(sqlIns, conn);
cmdIns.Parameters.Add("@ip", argv[0]);
cmdIns.Parameters.Add("@InOctets", Global.TrafficNew[0]);
cmdIns.Parameters.Add("@OutOctets", Global.TrafficNew[1]);
cmdIns.Parameters.Add("@TotalOctets", Global.TrafficNew[2]);
cmdIns.Parameters.Add("@Time", DateTime.Now);
cmdIns.ExecuteNonQuery();
cmdIns.Parameters.Clear();
cmdIns.CommandText = "SELECT @@IDENTITY";
// Get the last inserted id.
int insertID = Convert.ToInt32(cmdIns.ExecuteScalar());
cmdIns.Dispose();
cmdIns = null;
}
catch (Exception ex)
{
throw new Exception(ex.ToString(), ex);
}
finally
{
conn.Close();
}
VB.NET SQL ALL功能
Imports System.Data
Imports System.Data.SqlClient
Public Class Form1
Inherits System.Windows.Forms.Form
Public Function ShowPerson()
Dim connStr, selectCmd As String
connStr = "server=127.0.0.1; database=DB; uid=***; pwd=***;"
selectCmd = "Select * From PERSON Order By id_no DESC"
Dim conn As SqlConnection, myAdapter As SqlDataAdapter
Dim myDataSet As New DataSet()
conn = New SqlConnection(connStr)
conn.Open()
myAdapter = New SqlDataAdapter(selectCmd, conn)
myAdapter.Fill(myDataSet, "PERSON")
DataGrid1.DataSource = myDataSet.Tables("PERSON")
End Function
Public Function GetSqlStr(ByVal str As String) As String
Return Replace(str, "'", "''")
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ShowPerson()
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim connStr, insertCmd As String
connStr = "server=127.0.0.1; database=DB; uid=***; pwd=***;"
insertCmd = "Insert Into PERSON(name, id_position, tel, salary) Values('" & _
GetSqlStr(txtName.Text) & "','" & GetSqlStr(txtPosition.Text) & _
"','" & GetSqlStr(txtTel.Text) & "'," & Val(txtSalary.Text) & ")"
Dim conn As SqlConnection, cmd As SqlCommand
conn = New SqlConnection(connStr)
conn.Open()
cmd = New SqlCommand(insertCmd, conn)
cmd.ExecuteNonQuery()
ShowPerson()
End Sub
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
Dim connStr, updateCmd As String
connStr = "server=127.0.0.1; database=DB; uid=***; pwd=***;"
updateCmd = "update PERSON Set id_position = '" & GetSqlStr(txtPosition.Text) & _
"',tel = '" & GetSqlStr(txtTel.Text) & "', salary = " & _
Val(txtSalary.Text) & " Where name = '" & GetSqlStr(txtName.Text) & "'"
Dim conn As SqlConnection, cmd As SqlCommand
conn = New SqlConnection(connStr)
conn.Open()
cmd = New SqlCommand(updateCmd, conn)
cmd.ExecuteNonQuery()
ShowPerson()
End Sub
Private Sub btnDel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDel.Click
Dim connStr, delCmd As String
connStr = "server=127.0.0.1; database=DB; uid=***; pwd=***;"
delCmd = "Delete From PERSON Where name = '" & GetSqlStr(txtName.Text) & "'"
Dim conn As SqlConnection, cmd As SqlCommand
conn = New SqlConnection(connStr)
conn.Open()
cmd = New SqlCommand(delCmd, conn)
cmd.ExecuteNonQuery()
ShowPerson()
End Sub
End Class
Imports System.Data
Imports System.Data.SqlClient
Dim Bm As BindingManagerBase
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim selectCmd As String = "select id_no as 書號, name as 書名, price as 單價, qty as 數量 From BOOK"
Dim connStr As String = "Server=localhost; database=BOOKDB; uid=sa; pwd=;"
Dim conn As SqlConnection, myAdapter As SqlDataAdapter
Dim myDataSet As DataSet = New DataSet()
conn = New SqlConnection(connStr)
conn.Open()
myAdapter = New SqlDataAdapter(selectCmd, conn)
myAdapter.Fill(myDataSet, "BOOK")
Dim bindId As Binding = New Binding("Text", myDataSet, "BOOK.書號")
Dim bindName As Binding = New Binding("Text", myDataSet, "BOOK.書名")
Dim bindPrice As Binding = New Binding("Text", myDataSet, "BOOK.單價")
Dim bindQty As Binding = New Binding("Text", myDataSet, "BOOK.數量")
txtId.DataBindings.Add(bindId)
txtName.DataBindings.Add(bindName)
txtPrice.DataBindings.Add(bindPrice)
txtQty.DataBindings.Add(bindQty)
Bm = Me.BindingContext(myDataSet, "BOOK")
CheckBm()
End Sub
Private Function CheckBm()
If Bm.Position = 0 Then
btnFirst.Enabled = False
btnPrev.Enabled = False
btnNext.Enabled = True
btnLast.Enabled = True
ElseIf Bm.Position = Bm.Count - 1 Then
btnFirst.Enabled = True
btnPrev.Enabled = True
btnNext.Enabled = False
btnLast.Enabled = False
Else
btnFirst.Enabled = True
btnPrev.Enabled = True
btnNext.Enabled = True
btnLast.Enabled = True
End If
lblShow.Text = (Bm.Position + 1) & "/" & Bm.Count
End Function
Private Sub btnFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFirst.Click
Bm.Position = 0
CheckBm()
End Sub
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
If Bm.Position < Bm.Count - 1 Then
Bm.Position += 1
End If
CheckBm()
End Sub
Private Sub btnPrev_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrev.Click
If Bm.Position > 0 Then
Bm.Position -= 1
End If
CheckBm()
End Sub
Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLast.Click
Bm.Position = Bm.Count - 1
CheckBm()
End Sub
Select Case TabControl1.SelectedTab.ToString
Case "TabPage: {發送簡訊}"
........................
Case "XXXX"
2010年2月2日 星期二
訂閱:
文章 (Atom)