Zero Identity
Username: Password:
[Forgot Password?] [Not Registered?]

ZI Store Updates

Zi Store

Online Users

Registered Users: 2016
Latest Registration: yhamrodne
Online Users: 9
(0 Members, 9 Guests)

Poll

What should be done first on the ZI overhaul?
Find more staff (45%) [10 Votes]
Fix all bugs (36%) [8 Votes]
Make new features (not challenges) (9%) [2 Votes]
Get more content (challenges etc) (9%) [2 Votes]

[Poll Archive]

Kr0wKr0w

Avatar

Last Login:
2012-01-20
Joined:
December 11 2009 01:08
Experience:
2
(19 day(s) ago)
The crashed tables for registration and other stuff is easy to fix (using the Mysql command "REPAIR TABLE").
ttyler333ttyler333
php coder
Avatar

Last Login:
0000-00-00
Joined:
May 09 2008 01:45
Experience:
1095.2
(20 day(s) ago)
according to a friend the registration doesn't work.
hack4uhack4u
ZI Owner
Avatar

Last Login:
0000-00-00
Joined:
March 30 2008 22:30
Experience:
20492
(21 day(s) ago)
Please do keep a list of all the bugs. They might eventually get fixed.. lol.
Hunter XHunter X

Avatar

Last Login:
0000-00-00
Joined:
September 25 2010 15:44
Experience:
0
(02 month(s) ago)
What we could do is start compling a list of bugs on the Tasks page, so if and when development resumes the developers know what needs doing.
Kr0wKr0w

Avatar

Last Login:
2012-01-20
Joined:
December 11 2009 01:08
Experience:
2
(02 month(s) ago)
Kewl, the domain renewed another year. :) Any other future plans?
Hunter XHunter X

Avatar

Last Login:
0000-00-00
Joined:
September 25 2010 15:44
Experience:
0
(02 month(s) ago)
I've got no idea. I'll send off an email to one of the admins in a moment to check, since I've been meaning to contact them anyway.
Hunter XHunter X

Avatar

Last Login:
0000-00-00
Joined:
September 25 2010 15:44
Experience:
0
(02 month(s) ago)
There seems to be ~10 guests on most days, but I have no idea if that's genuine users or crawler bots. If they are real users we need to do something to convince them to register.


Icon Zero Identity Forums - General - Programming - VB Project Help Needed


Are you bored? Check out the unaswered threads!

bugsbunny
Member


Avatar
Trainee

Joined: 07/05/2010
Last Seen: 0000-00-00
Experience: 158.3
Points:
#1 VB Project Help Needed on 01/01/1970 00:00
Guys,

Please help me with the following code. I am trying to connect with MS Access database to save records. I am using Visual Studio 2008. I have typed the following code to save a record. Kindly help me by telling where I am wrong.

**********
Imports System.Data.OleDb

Public Class Form1
Inherits System.Windows.Forms.Form
Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader
Dim icount As Integer
Dim str As String

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Try
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source = C:Documents and SettingsAdministratorDesktopNew_Database1.mdb")
'provider to be used when working with access database
cn.Open()
cmd = New OleDbCommand("select firstname, lastname, designation, age from IO", cn)
dr = cmd.ExecuteReader
While dr.Read()
TextBox1.Text = dr(0)
TextBox2.Text = dr(1)
TextBox3.Text = dr(2)
TextBox4.Text = dr(3)
' loading data into TextBoxes by column index
End While
Catch
End Try
dr.Close()
cn.Close()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source = C:New_Database1.mdb")
cn.Open()
str = "insert into IO values(" & TextBox1.Text & ",'" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text &"')"
'string stores the command and CInt is used to convert number to string
cmd = New OleDbCommand(str, cn)
icount = cmd.ExecuteNonQuery
MessageBox.Show(icount)
'displays number of records inserted
Catch
End Try
cn.Close()
End Sub
End Class
**********
bugsbunny
Member


Avatar
Trainee

Joined: 07/05/2010
Last Seen: 0000-00-00
Experience: 158.3
Points:
#2 on 01/01/1970 00:00
Guys, please help me with this.
3l_f3n1x
Member
V Fan

Avatar
Professional Analyst

Joined: 08/06/2008
Last Seen: 0000-00-00
Experience: 299.25
Points: 905
#3 A better approach to write SQL statements on 01/01/1970 00:00
I don't know anything about VB, but it's a terrible practice in any language to do this:

Code Highlighting :: Select Code
str = "insert into IO values(" & TextBox1.Text & ",'" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text &"')"


Eventually your code will be hard to maintain. There are better and secure ways of dealing with that problem (I don't know if they exist in VB, but looking for them worth a shot).

For example in Haskell you can do this:

Code Highlighting :: Select Code

1  example :: a  -- ^ First TextBox content.
2          -> b  -- ^ Second TextBox content.
3          -> c  -- ^ Third TextBox content.
4          -> d  -- ^ Fourth TextBox content.
5          -> IO ()
6  example tb1 tb2 tb3 tb4 = do
7      dbh <- connectSqlite3 "example.db"
8      run dbh "INSERT INTO IO VALUES(?, ?, ?, ?)"
9              [toSql tb1, toSql tb2, toSql tb3, tb4]
10     commit dbh
11     disconnect dbh


I want you to focus on the lines 8 and 9. There you can see a call to a function called "run". You give to that function the Database Handler (dbh), the SQL statement with question marks where you want the data to be inserted, and a list with the data you want to insert. This way the SQL statements are much clearer, and maintaining this code it's a lot easier for the reader.

Another example, this time in Java:

Code Highlighting :: Select Code

(...)
1  PreparedStatement ps = connection.prepareStatement(
2      "SELECT email FROM member WHERE name = ?");
3  ps.setString(1, formField);
4  ResultSet rs = ps.executeQuery();
(...)


As you can see in line 2, the SQL statement and the question mark. The line 3 just replace the question mark for the formField.

And now that you know the idea, this is a Perl example:

Code Highlighting :: Select Code

(...)
$sth = $dbh->prepare("SELECT email, userid FROM members WHERE email = ?;");

$sth->execute($email);
(...)


These approaches are SQL injection proof. So the resultant code is maintainable and secure: The dream of every software developer.

That's just an advice.

BTW, for the people that read your posts would be clearer if you post your code between the code tags, that way we'll see the indentation in your code and no smileys in it. =D

I hope this help.

P.S: I know some of you are allergic to functional programming. Sorry for the inconveniences.

"Beneath this mask there is more than flesh. Beneath this mask there is an idea, Mr. Creedy, and ideas are bulletproof." - V

BTW: My username was elfenix


Who is watching forums


Users viewing this page: Guests (1)
Users viewing the forum: 1