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

انا رفعت قاعدة بيانات على موقع مجاني من نوع mysql

واستخدمت عدة اكواد على الفيجوال بيسك دوت نت بدون فائدة
وهذا هو الكود الذي استخدمه في الفيجوال بيسك

PHP كود :
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 database. This class cannot be inherited.
    Dim da As New MySqlDataAdapter

    Private Sub btncreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 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.Object, ByVal e As System.EventArgs) Handles 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,listview, etc...
    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.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class 

لم اجد الطريقة في بعض مواقع الانترنت واتمنى ان اجدها هنا

علما بأن قاعدة البيانات مستخدمه في موقع مجاني اسمه
hostinger.ae

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


الردود في هذا الموضوع
ماهي طريقة الاتصال بقاعدة البيانات الموجودة في موقع الانترنت - بواسطة php3 - 28-08-14, 09:38 AM

المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  استفسارات عن قواعد البيانات مبتدئ بوحمد 0 1,009 06-11-24, 10:15 AM
آخر رد: بوحمد
  [C#.NET] مشكلة في مجلد قاعدة البيانات kamel1978 3 688 06-10-24, 06:26 PM
آخر رد: Taha Okla
  ما هو كود معرفة نوع البيانات من اكسس؟ justforit 6 1,046 23-05-24, 08:22 AM
آخر رد: مصمم هاوي
  [سؤال] حول مشكلة توافق نوع البيانات عند الاستعلام في اكسل justforit 4 695 23-05-24, 05:35 AM
آخر رد: justforit
  ماهي الجداول التي احتاجها لنظام رواتب متكامل Adel27213 0 637 03-11-23, 09:41 PM
آخر رد: Adel27213
  مشكلة عند الاتصال ب sql server 2014 bassant 1 1,328 27-08-23, 12:26 PM
آخر رد: رضوان الجماعي
  [سؤال] عدم إظهار الصور مع النص فى Listview من قاعدة البيانات alims 2 2,035 27-08-23, 12:22 PM
آخر رد: رضوان الجماعي
  [SQL] استفسار عن طريقة تحزم قواعد بيانات MSSQL مع البرنامج VB.NET2019 salemq 2 867 18-05-23, 03:02 AM
آخر رد: سعود
  استفسار عن تخزين الوقت في قاعدة البيانات strongriseman 2 1,570 22-04-22, 07:27 PM
آخر رد: strongriseman
  [سؤال] مشكلة فى عرض الصورة من ادخل قاعدة البيانات alims 2 1,708 17-11-21, 10:09 AM
آخر رد: سعود

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


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