تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[سؤال] ماهي المشكلة في مشروعي . ربط قاعدة بيانات mysql
#3
هذا الكود المستخدم في زر جلب البيانات من القاعدة



PHP كود :
Private Sub btnload_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles btnload.Click
        
'again we do this because we do not yet declare this as global, but we do it for now beacause in later tutorial
        '
we will do the moduling and more on refactoring of codes
        con
.ConnectionString = ("server=localhost;user id=root;password=;database=androidhive")
        Try
            
con.Open()
            
With cmd
                
.Connection con
                
'in this query it does simply selecting or getting all the user found in the database.
                .CommandText = "Select * from products"
            End With

        Catch ex As Exception
            MsgBox(ex.Message)


        End Try
        con.Close()
        da.Dispose()
        filltable(dtguser)

    End Sub 


هذا كود الخطأ

unable to convert mysql date/time value to system.datetime


وهذا الكود كامل المستخدم في الفورم





PHP كود :
'Description: This program can able to insert and read user form the MySQL Database using Visual Basic.
'
Author:      Joken Villanueva
'Date Created: 
Imports System.Data
Imports MySql.Data.MySqlClient
Public Class Manage_user
    Dim con As New MySqlConnection
    Dim result As Integer
    '
MySqlCommand It represents a SQL statement to execute against a MySQL Database
    Dim cmd 
As New MySqlCommand
    
'Represents a set of data commands and a database connection that 
    '
are used to fill a dataset and update a MySQL databaseThis class cannot be inherited.
    
Dim da As New MySqlDataAdapter

    
Private Sub btncreate_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles btncreate.Click
        
'this line of is simply we copy this one from our form 
        con.ConnectionString = ("server=localhost;user id=root;password=;database=androidhive")

        Try
            '
we open Connection
            con
.Open()

            
With cmd
                
.Connection con
                
.CommandText "INSERT INTO `androidhive`.`products` (`pid`, `name`, `price`, `description`) " _
                                
"VALUES (NULL, '" txtfullname.Text "', '" txtusername.Text "', '" txtpassword.Text "');"
                'in this line it Executes a transact-SQL statements against the connection and returns the number of rows affected 
                result = cmd.ExecuteNonQuery
                '
if the result is equal to zero it means that no rows is inserted or somethings wrong during the execution
                
If result 0 Then
                    MsgBox
("Data has been Inserted!")
                Else
                    
MsgBox("Successfully saved!")

                
End If
            
End With
        
Catch ex As Exception
            MsgBox
(ex.Message)
        
End Try
        
con.Close()
    
End Sub

    
Private Sub btnload_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles btnload.Click
        
'again we do this because we do not yet declare this as global, but we do it for now beacause in later tutorial
        '
we will do the moduling and more on refactoring of codes
        con
.ConnectionString = ("server=localhost;user id=root;password=;database=androidhive")
        Try
            
con.Open()
            
With cmd
                
.Connection con
                
'in this query it does simply selecting or getting all the user found in the database.
                .CommandText = "Select * from products"
            End With

        Catch ex As Exception
            MsgBox(ex.Message)


        End Try
        con.Close()
        da.Dispose()
        filltable(dtguser)

    End Sub
    ' 
this our sub procedure that well always used 
    
'this beacause it always catch all the result query 
    '
and it will display to any kind of visual basic containers like datagridview,listbox,listviewetc...
    Public 
Sub filltable(ByVal dtgrd As Object)
        
'declare a variable as new datatable
        Dim publictable As New DataTable
        Try
            '
Gets or sets an SQL statement or stored procedure used to select records in the database.
            
da.SelectCommand cmd
            da
.Fill(publictable)
            
dtgrd.DataSource publictable
            dtgrd
.Columns(0).Visible False

            da
.Dispose()

        Catch 
ex As Exception
            MsgBox
(ex.Message)

        
End Try

    
End Sub

    
Private Sub Manage_user_Load(ByVal sender As System.ObjectByVal e As System.EventArgsHandles MyBase.Load

    End Sub
End 
Class 
الرد }}}
تم الشكر بواسطة:


الردود في هذا الموضوع
RE: ماهي المشكلة في مشروعي . ربط قاعدة بيانات mysql - بواسطة php3 - 25-08-14, 08:28 AM

المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  تصدير بيانات من سيكوال bassant 1 241 29-09-25, 01:11 AM
آخر رد: justforit
Heart استرجاع قاعدة بيانات محمد بن عطية 1 1,073 18-07-25, 04:30 AM
آخر رد: abuabdulrhman
  [C#.NET] مشكلة في مجلد قاعدة البيانات kamel1978 3 691 06-10-24, 06:26 PM
آخر رد: Taha Okla
  [سؤال] سؤال حول منع تكرار بيانات عند تعديلها justforit 1 573 07-05-24, 12:09 AM
آخر رد: justforit
  استعلام من عدة جداول لقاعدة بيانات اكسس Adel27213 1 1,267 07-11-23, 08:27 AM
آخر رد: justforit
  ماهي الجداول التي احتاجها لنظام رواتب متكامل Adel27213 0 640 03-11-23, 09:41 PM
آخر رد: Adel27213
  [سؤال] عدم إظهار الصور مع النص فى Listview من قاعدة البيانات alims 2 2,040 27-08-23, 12:22 PM
آخر رد: رضوان الجماعي
  [SQL] استفسار عن طريقة تحزم قواعد بيانات MSSQL مع البرنامج VB.NET2019 salemq 2 871 18-05-23, 03:02 AM
آخر رد: سعود
  ما معني بيانات تقع بين الرمز[] في حقل في داتا بيس bassant 3 1,059 03-04-23, 11:53 PM
آخر رد: sanyor77
  [نقاش] مشاركة قاعدة بيانات SQL على شبكه داخليه morkoskhalaf 3 3,581 06-01-23, 03:20 AM
آخر رد: عبدالكريم برشدان

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم