Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
Z

zaimah

@zaimah
About
Posts
72
Topics
19
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • How to INSERT multiple rows of data to sql table?
    Z zaimah

    is there a way for me to insert all using this coding? lets say i have 10 record, how can i use this code to insert each record that i key-in? i want to insert 10 or more records at a time. I manage to UPDATE multiple record using one button on grid view. But for INSERT, i can only manage to INSERT record one by one. Is there a way for me to INSERT lets say 10 records at a time?

    Visual Basic question database tutorial

  • How to INSERT multiple rows of data to sql table?
    Z zaimah

    that is what im trying to do.. Insert the student.. How can i do that? Insert a list of student? after that, it would be easier for me to use UPDATE because the student exist in the student table. I have table for student so i can set their course in table course.

    Visual Basic question database tutorial

  • How to INSERT multiple rows of data to sql table?
    Z zaimah

    Its a bit confusing rite now for me. The lecturer job is to register the student to the table "student". What do u mean by the student will have to exist before the list can be save? Do u mean i have to type manually to the table "student"? Been trying to find Insert from html table to sql table but keep on seeing from sql table to html table... Can tableadapter used for webform?

    Visual Basic question database tutorial

  • How to INSERT multiple rows of data to sql table?
    Z zaimah

    sorry, maybe my explanation is not clear. I already have a table "student". And i have a web form where the lecturer can insert a list of new student. I cannot use gridview not because the table doesn't exist, just the data does not exist yet until the lecturer key-in the data. i know how to use sqldataAdapter to retrieve value from sql table and put it in a textbox. But that is if the data exist. Will try to look for tableadapter. Sorry again, i waited and at the same time been searching for solution all over the place for any articles related to my problem. TQ for your reply..

    Visual Basic question database tutorial

  • How to INSERT multiple rows of data to sql table?
    Z zaimah

    sorry.. still cant understand how it works. i have a html table where there are 3 columns studentID,studentName, courseName. There ada 10 rows of textbox for each column. Can u explain how can i use the one that u gave me? I'm not using gridview because my data doesn't exist in the sql table yet. Hope my explanation is clear because my english is not that good.. TQ for the reply... been waiting every minutes for reply :)

    Visual Basic question database tutorial

  • How to INSERT multiple rows of data to sql table?
    Z zaimah

    Hi, anyone can give me idea on how to do this? I'm used to gridview for updating multiple data to sql table. But how can i insert to sql table a list of data from a table/form? Its a situation where a lecturer wants to register a list of student for a subject.

    Visual Basic question database tutorial

  • [SOLVED] How to update Gridview with value textbox = Null
    Z zaimah

    :) It WORKS... yayyyy.. if i put empty textbox it will put 0 to my table... THANK YOU A LOT :) my code would be like this ...

    Dim C1S As String = DirectCast(row.FindControl("Label1"), TextBox).Text
    Dim C1 As Integer = 0
    Integer.TryParse(C1S, C1)

    Can u pls explain to me how it works? I think i sleep with a smile on my face tonite.. Its 12midnite rite now at my place... I've been building this prgm learning to do it by google.. Cannot find anyone to teach so i turn to Google.. But when this error come out... I cannot find the solution in google... THANK YOU AGAIN :) :) :) :)

    Visual Basic html sysadmin help tutorial announcement

  • [SOLVED] How to update Gridview with value textbox = Null
    Z zaimah

    ok.. I'm in trouble rite now.. Suddenly it cannot update anything.. :( i have to submit this prgm tomorrow... :(( 1st time i learn doing this kind of prgm last year.. but only did this once. after almost a year, i have to do this project because im studying rite now. I learn to do this in 2 weeks.

    Visual Basic html sysadmin help tutorial announcement

  • [SOLVED] How to update Gridview with value textbox = Null
    Z zaimah

    I did like your told me.. But the error is still the same.. I try to using this

            Dim C1S As String = DirectCast(row.FindControl("Label1"), TextBox).Text
            Dim C1 As Integer = Integer.TryParse(C1S, C1)
    

    It works... it can update even with null value textbox. But another probem happens.. All of my value turn as negative in my table.. If i enter 1, it will be -1 in my table..

    Visual Basic html sysadmin help tutorial announcement

  • [SOLVED] How to update Gridview with value textbox = Null
    Z zaimah

    i did like this

            Dim C1S As TextBox = DirectCast(row.FindControl("TextBox1"), TextBox)
            Dim C1 As Integer = Convert.ToInt32(C1S)
    

    And the error is this:

    [InvalidCastException: Unable to cast object of type 'System.Web.UI.WebControls.TextBox' to type 'System.IConvertible'.]
    System.Convert.ToInt32(Object value) +18

    How can this be? my textbox suppose to have number as input not string. So i used convert.int32. Is this the correct way?

    Visual Basic html sysadmin help tutorial announcement

  • [SOLVED] How to update Gridview with value textbox = Null
    Z zaimah

    Do u mean the example that u gave me:

    Dim C1S As Integer = DirectCast(row.FindControl("Label1"), TextBox).Text
    Dim C1 As Integer = Convert.ToInt32(C1S)

    I have try using this method. It didn't work. How to check the value 1st and if its Null, put '0' in it? the one that i put convert.dbnull is one of my testing. sorry for the confusion. Sorry, my english s not that good :(

    Visual Basic html sysadmin help tutorial announcement

  • [SOLVED] How to update Gridview with value textbox = Null
    Z zaimah

    Not always. If C1-C5 have value, and C6 is empty, then the error would be on C6. The weird thing is, the error only occur at textbox that are empty. It runs OK when there's no empty textbox.

    Visual Basic html sysadmin help tutorial announcement

  • [SOLVED] How to update Gridview with value textbox = Null
    Z zaimah

    the name for textbox is Label1.. Sorry for the confusion :) :) Originally, the gridview only have edit button for each row of data in gridview. So i change my gridview in html. I change all the label to textbox and bound the text box. So i would only have one button to update everything that i key-in in the gridview. After i change the label to textbox, lazy of me, im not changing the name of the previous label ;P Would that effect the coding? But i can update the data. The problem is only when one of the textbox is empty. If the textbox that i cast for C10 is empty, then the error would be on C10, not C1.

    Visual Basic html sysadmin help tutorial announcement

  • [SOLVED] How to update Gridview with value textbox = Null
    Z zaimah

    It didn't work with the same error. before this, the error is at:

    Dim C1 As Integer = DirectCast(row.FindControl("Label1"), TextBox).Text

    after i edit using your suggestion, the error is at:

    Dim C1S As String = DirectCast(row.FindControl("Label1"), TextBox).Text

    its as if it didn't even reach the convert part, the error occurred.. I have try similar method, trying to convert the value so that it can update the value Null to my table, but the error is still at the find control.. Is there something wrong with my coding at find control part? But the update is successful, except when the value is NULL.. This really gives me a headache.. Thanks for replying my question :) Is there any solution?

    Visual Basic html sysadmin help tutorial announcement

  • [SOLVED] How to update Gridview with value textbox = Null
    Z zaimah

    Hi, its been years i don't do vb. So its like im a junior in this. I have problem update my Gridview. My gridview is to update marks for student. The problem is, the update have problem if the textbox is with a NULL value. If i put 0 in the textbox, the update runs ok. This is my gridview html

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource2">
    <Columns>
    <asp:TemplateField HeaderText="Student ID" SortExpression="stID">
    <ItemTemplate>
    <asp:Label ID="Label11" runat="server" Width="50px" Text='<%# Bind("stID") %>'></asp:Label>
    </ItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="CO1" SortExpression="CO1">
    <ItemTemplate>
    <asp:TextBox ID="Label1" runat="server" Width="50px" Text='<%# Bind("CO1") %>'></asp:TextBox>
    </ItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="CO2" SortExpression="CO2">
    <ItemTemplate>
    <asp:TextBox ID="Label2" runat="server" Width="50px" Text='<%# Bind("CO2") %>'></asp:TextBox>
    </ItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="CO3" SortExpression="CO3">
    <ItemTemplate>
    <asp:TextBox ID="Label3" runat="server" Width="50px" Text='<%# Bind("CO3") %>'></asp:TextBox>
    </ItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="CO4" SortExpression="CO4">
    <ItemTemplate>
    <asp:TextBox ID="Label4" runat="server" Width="50px" Text='<%# Bind("CO4") %>'></asp:TextBox>
    </ItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="CO5" SortExpression="CO5">
    <ItemTemplate>
    <asp:TextBox ID="Label5" runat="server" Width="50px" Text='<%# Bind("CO5") %>'></asp:TextBox>
    </ItemTemplate>
    </asp:TemplateField>

    Visual Basic html sysadmin help tutorial announcement

  • make sure that the max index on a list is less than the list size
    Z zaimah

    i know my code sucks bcoz this is my 2nd time doing a prgm n b4 this i dont even know how to use vb or vb.net at all. it would be great if u give me any related article regarding issues 1 n 2. as i said b4 in my previous post (not this one but the same problem) my english r not that good, so whenever i try to google my problem, i cannot find any related article to my problem. i know u dont have time to entertain my stupid question, but if u can pls give the related link. im quite confused why it run ok n suddenly it cannot bcoz i didnt do any editing on ds.table part and it can retrieve data from table b4 this. tq

    Visual Basic help csharp css database security

  • make sure that the max index on a list is less than the list size
    Z zaimah

    hi, iv got this prgm where i choose a file, read the data in the file, compare it with a directory whether data in that file r in that directory.. data in the file 20090101 C1234 B0018 20090211 C1234 B0150 20090228 C5678 BRT10 20090228 C5678 BP001 when i debug the prgm, the error happen in convertCoop(coop) at Catch Ex As Exception.. b4 Catch part, the value of coop can be retrieve, but when i try to put values from table kodPortal to portal that is portal = ds.Tables(0).Rows(0).Item("portal"), at this part, no values are enter to portal. the error at catch is "make sure that the max index on a list is less than the list size". before this the prgm can run and come out with an output, but when i choose file that have no extension, the error come out.. after i did some editing, now any file that i choose have the same error. Pls help me... i have been posting this msg at several forum, but no one can help me..

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim fdlg As OpenFileDialog = New OpenFileDialog()
        fdlg.Title = "C# Corner Open File Dialog"
        fdlg.InitialDirectory = "c:\\"
        fdlg.Filter = "All files (\*.\*)|\*.\*|All files (\*.\*)|\*.\*"
        fdlg.FilterIndex = 2
        fdlg.RestoreDirectory = True
    
        If fdlg.ShowDialog() = Windows.Forms.DialogResult.OK Then
            TextBox1.Text = fdlg.FileName
        End If
    
    
    
    
    End Sub
    

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        Dim folderopen As New FolderBrowserDialog
        With folderopen
            .RootFolder = Environment.SpecialFolder.Desktop
            .SelectedPath = "C:\\DOCUMENT"
            .Description = "Select the source directory"
            If .ShowDialog = Windows.Forms.DialogResult.OK Then
                ' Display the selected folder if the user clicked on the OK button.
                MessageBox.Show(.SelectedPath)
                TextBox2.Text = .SelectedPath
            End If
    
        End With
    End Sub
    

    Private Sub convertCoop(ByVal coop As String)

        Dim conn1 As New SqlClient.SqlConnection("Data Source=10.0.0.70;User ID= sysadm;Password=sysadm;Initial Catalog=SPGA\_Latihan;Persist Security Info=True;")
        Dim comm As SqlClient.SqlDataAdapter = Nothing
        Dim ds As DataSet = New DataSet()
        Dim strSQL2 As String = "SELECT folder, portal FROM kod
    
    Visual Basic help csharp css database security

  • index out of range exception
    Z zaimah

    i dont have any problems with my substring.. i can read data from file using that code.. as u can see my reply at Christian answers, the problem start if i choose directory that have thousands of folder n files. but if a choose a directory that have just a few folder n files.. it can run and can get output from the prgm..

    Visual Basic help database security tutorial

  • index out of range exception
    Z zaimah

    i am using the debugger.. the thing is, i can read data from the files but when it comes to this part in convertCoop, i cannot get value from "portal" but the value of "coop" is ok. after this part, at the Catch part, the msg "index out of range exception" come out. is it bcoz the directory that i choose got a lot (thounsands) of folder n files? bcoz when i choose directory that only have a few folders n files, it runs smoothly.. no errors, and i can see all the missing files in that directory.

    portal = ds.Tables(0).Rows(0).Item("portal")

    Visual Basic help database security tutorial

  • index out of range exception
    Z zaimah

    im running this function to convert a list of code into a certain standard.. the problem is, when i choose the files (where i get the value of coop) and directory (where i compare coop with the list in the directory) this msg come out "index out of range exception". But if i choose local file and directory example file from my desktop and my d:/ there's np error.. but if i choose the file from other map drive the error happen at the Catch part.

    Private Sub SEMAK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SEMAK.Click

        Dim fileName As String = TextBox1.Text.Trim
        Dim lineNumber As Integer = 0
        Dim sr As StreamReader = New StreamReader(fileName)
        Dim conn As New SqlClient.SqlConnection("Data Source=10.0.0.70;User ID= sysadm;Password=sysadm;Initial Catalog=SPGA\_Latihan;Persist Security Info=True;")
    
        Dim tarikh As String = ""
        Dim runNo As String = ""
        Dim coop As String = ""
        Dim line As String = ""
    
    
        Do
            line = sr.ReadLine()
    
            If line <> Nothing Then
                Try
                    tarikh = line.Substring(0, 8).Trim()
                    runNo = line.Substring(9, 5).Trim()
                    coop = line.Substring(15).Trim()
    
                Catch ex As Exception
                    Console.Write(ex.ToString())
                End Try
    
                Dim strSQL As String = "INSERT INTO portal (tarikh,runNo, coop) VALUES (@tarikh, @runNo, @coop)"
                Dim cmd As New System.Data.SqlClient.SqlCommand(strSQL, conn)
    
                conn.Open()
    
                cmd.Parameters.Add(New SqlClient.SqlParameter("@tarikh", SqlDbType.Char, 8))
                cmd.Parameters("@tarikh").Value = tarikh
    
                cmd.Parameters.Add(New SqlClient.SqlParameter("@runNo", SqlDbType.Char, 20))
                cmd.Parameters("@runNo").Value = runNo
    
                cmd.Parameters.Add(New SqlClient.SqlParameter("@coop", SqlDbType.VarChar, 100))
                cmd.Parameters("@coop").Value = coop
    
                cmd.ExecuteNonQuery()
                conn.Close()
                
                Dim dirB1 As DirectoryInfo = New DirectoryInfo(TextBox2.Text)
    
    
    
    
    
                Try
    
                    convertCoop(coop)
    
    
    
                    Dim dA1 As DirectoryInfo
                    Dim dirB2 As FileSystemInfo() = dirB1.GetDirectories
    
                    Dim strSQL2 As String = "SELECT folder, portal FROM  kodPortal"
    
    Visual Basic help database security tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups