CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2009
    Posts
    4

    Lightbulb fill form fields

    I am working on Visualbasic -2008 express edition and mysql as database.I am able to establish the connection with database table.I am strucked in how to fill the form fields and datgrid..I have date,partno,quotes,customer fields on a form.Have a look at the connection
    help me to fill the form fields and datagrid
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset
    cn = New ADODB.Connection
    rs = New ADODB.Recordset
    cn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" + "SERVER=localhost;" + "DATABASE=in_out;" + "UID=root;" + "PASSWORD=pacvision;" + "dsn=in_out:" + "OPTION=3;"
    'cn.ConnectionString = Cnstr
    cn.Open()
    MessageBox.Show("Connection Opened Successfully")
    rs.Open("Select * from deptno", cn.ConnectionString, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)

  2. #2
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: fill form fields

    In .NET you don't use ADODB, you should rather use MySQL Connector. If you search for MySql Connector in google, you will lot of samples too. Take a look at those samples and see if they will help you.

  3. #3
    Join Date
    Jul 2009
    Posts
    4

    Re: fill form fields

    Quote Originally Posted by Shuja Ali View Post
    In .NET you don't use ADODB, you should rather use MySQL Connector. If you search for MySql Connector in google, you will lot of samples too. Take a look at those samples and see if they will help you.
    Ali,apreciable to you suggestion.I used MySql Connector and completed the task.
    I have one question to you,I am adding values to database from form fields using insert Query but the quey is not executing.have a look at the query
    Console.WriteLine(updateRecord("insert into quotes(date,PartNo,Customer)values('" + txtDate.Text + "','" + txtpartnumber.Text + "','" + txtCustomer.Text + "')"))
    I am using VB2008 environment

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: fill form fields

    Don't use reserved words in queries or field names. Date is.

    Also, dates aren't STRING, or TEXT. You need to convert to a valid date, so always check values before adding them to your tables
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured