  | 
		 		   | 
	  	    
          
            
			
	
			
			 
                 Code (VB.NET) 
[color=blue]Private Sub Add_Proj_Click()
    Dim sqlStr As String
    Dim conn As New ADODB.Connection
    Dim sqlCm As New ADODB.Command
    Dim rs As New ADODB.Recordset
    
    sqlStr = "Driver={MySQL ODBC 5.1 Driver};Server=localhost;Port=3307;Database=vb_project;Uid=root;Pwd=admin;"
    
    conn.ConnectionString = sqlStr
    
    conn.Open
    
    Dim Statement As String
     Statement = "INSERT INTO project" & _
        "(PROJECT_CODE,CUSTOMER_CODE,PROJECT_NAME,CP_NAME,CP_TEAM,SM_NAME,PS_NAME,OPP,START_SALE_DATE," & _
        "CLOSE_SALE_DATE,SW_COST,SW_GP,HW_COST,HW_GP,PS_COST,PS_GP,TOTAL_COST,TOTAL_GP,USER_DATE,USER_ID) " & _
        " VALUES (" & _
        "'" & Proj_code.Text & "', " & _
        "'" & Cus_code_proj.Text & "', " & _
        "'" & Proj_name.Text & "', " & _
        "'" & CP_name.Text & "'," & _
        "'" & CP_Team.Text & "'," & _
        "'" & SM_name.Text & "'," & _
        "'" & PS_name.Text & "'," & _
        "'" & OPP_txt.Text & "'," & _
        "'" & Start_date.Text & "'," & _
        "'" & Close_date.Text & "'," & _
        "'" & SW_cost.Text & "'," & _
        "'" & SW_GP.Text & "'," & _
        "'" & HW_cost.Text & "'," & _
        "'" & HW_GP.Text & "'," & _
        "'" & PS_cost.Text & "'," & _
        "'" & PS_GP.Text & "'," & _
        "'" & Total_Cost.Text & "'," & _
        "'" & Total_GP.Text & "'," & _
        "'" & User_date.Text & "'," & _
        "'" & User_ID.Text & "'," & _
        ")"
        
     conn.Execute Statement, , adCmdText
     conn.Close
    
    MsgBox "Add Done", vbOKOnly, "Done"
    
   ' Cus_code.Text = ""
    'Cus_name.Text = ""
    'CP_name.Text = ""
    
   ' User_ID.Text = ""
    
    
    'Call ConnToDB
    'DataGrid1.Refresh
    Exit Sub
ErrorHandler: MsgBox Err.Description, , "Error"
End Sub
 
 
 
 
 
  Tag : MySQL, VB.NET               
                        | 
           
          
            
		
  ประวัติการแก้ไข 2011-12-13 10:07:30	
                             | 
           
          
            
              
                   | 
                   | 
                   | 
               
              
                   | 
                
                    
                      | Date :
                          2011-12-13 09:52:47 | 
                      By :
                          เด็กกระทิง | 
                      View :
                          1366 | 
                      Reply :
                          3 | 
                     
                  | 
                   | 
               
              
                   | 
                   | 
                   | 
               
              | 
           
          
            | 
			 | 
           
         
	    
		             | 
		
			  |