Latest Posts in Software Development

Re: in Java
 
0
 

If you need Java code for your homework then you have to write it yourself; nobody here will do your homework for you. If you make an effort, and get stuck, post what you have done so far, and people here will help you.

Re: in Python
 
0
 

There is no backslash in your string, so I don't see the problem. there is only an ordinary slash, which has no special effect. Please describe what you expect.

in Python
 
0
 

I'm doing a multi-line string saved to the variable str:

str = """
This is a multiline string
"""

When I print str it works fine. But if I print a different multiline string:

`

str = """
This is a multiline string
"""

print str             # Works Fine

str_2 = """

hi/hola!
goodbye               # Backslashes don't work

"""

Can someone help.

Re: in Java
 
0
 

Kishore_5 : this is an unrelated matter to an old thread.
Please don't hijack threads, but start your own.

in C#
 
0
 

please how do i insert and retrieve image from sql db in asp.net mvc app and before inserting the image, the user can resize the image before inserting it.

Re: in VB.NET
 
0
 

Hi Christopher,

Use an indicator as departmentId so that you can login to either department1 or department2. And use parameterized query to avoid sql injection attack.

Private strCon As String = "Data Source=IT-Hardz\SqlExpress;Initial Catalog=CGHMS;Integrated Security=True "
    Private Sub btnLogIn_Click(sender As System.Object, e As System.EventArgs) Handles btnLogIn.Click
        Dim cmd As New SqlCommand()
        Using con As New SqlConnection(strCon)
            con.Open()
            cmd.Connection = con
            cmd.CommandText = "Select log_username, log_password, DepartmentId From Login Where log_username = @username And " + "log_password = @password "
            cmd.Parameters.AddWithValue("@username", txtUserName.Text)
            cmd.Parameters.AddWithValue("@password", txtPassword.Text)
            Using dr As SqlDataReader = cmd.ExecuteReader()
                Dim indicator As Boolean = False
                While dr.Read()
                    Dim mydept As String = dr("DepartmentId").ToString()
                    If dr.HasRows AndAlso mydept = "1" Then
                        MessageBox.Show("Department1")
                        department1.Show()
                        indicator = True
                    ElseIf dr.HasRows AndAlso mydept = "2" Then
                        MessageBox.Show("Department2")
                        department2.Show()
                        indicator = True
                    End If
                End While
                If Not indicator Then
                    MessageBox.Show("Invalid User name and password")
                End If
            End Using
        End Using
    End Sub

Hardz

Re: in VB.NET
 
0
 

I would rather process one excel cell, instead of first reading in a whole excel row and concatenating the cell values as string an then start to process the string. But that depends upon you, the programmer.

in VB.NET
 
0
 

Hi guys!

I'm getting frustrated with my code because my filter in my query is not working.

All of the item_model in my receiving_details table were being suggested in auto complete but as you can see in my query that I'm filtering item model with a certain form_no.

Please help me.. Thank you.

    Private Sub item_suggest()

        Try

            SQLconn = New SqlConnection
            SQLconn.ConnectionString =
                "server=TOSOT_IT\TOSOT_SERVER;user=sa;password=cblls7890;database=TOSOT_DATABASE;"

            SQLconn.Open()

            Dim dt As New DataTable
            Dim ds As New DataSet
            ds.Tables.Add(dt)


            Dim da As New SqlDataAdapter(" SELECT item_model FROM receiving_details WHERE form_no= '" & txtFROM_NO.Text & "' ", SQLconn)
            da.Fill(dt)


            Dim r As DataRow

            txtITEM_MODEL.AutoCompleteCustomSource.Clear()

            For Each r In dt.Rows
                txtITEM_MODEL.AutoCompleteCustomSource.Add(r.Item(0).ToString)

            Next
            SQLconn.Close()


        Catch ex As Exception
            MessageBox.Show(ex.ToString)


        End Try
    End Sub
Re: in VB.NET
 
0
 

Thank you very much Sir ddanbe and sir Hardz;

Few more questions sir,

Dim exdata As String() = {"98321 12345 67890 54321 09876", "89123 51234 06789 15432 60987"}

'can I use this code if I base on a Excel file?
'I'm exporting an Excel file to DataGridView.
'can help me how?
Re: in Java
 
0
 

i want to give access to my clients using java.when i tried the code it is showing "com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Access denied for user 'root'@'183.83.51.134' to database 'printer_system_master'

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */


/**
 *
 * @author hesperus
 */

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.sql.*;
import javax.swing.JOptionPane;

public class Provide_db_privillages {
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
            try {
                URL connection1 = new URL("http://checkip.amazonaws.com/");
                URLConnection con = connection1.openConnection();
                String ip = null;                
                BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream()));
                ip = reader.readLine();
                Class.forName("com.mysql.jdbc.Driver");
                Connection connection = DriverManager.getConnection("jdbc:mysql://52.74.143.118:3306/printer_system_master", "root", "root");
//                Connection con = getDBConnection();
                Statement stmt = connection.createStatement();
                String query = "GRANT INSERT,SELECT,UPDATE,DELETE ON printer_system_master.* TO 'printer_system_master.root'@'" + ip + "' IDENTIFIED BY 'printer_system_master.root'";
                stmt.execute(query);
                System.out.println(query);
                JOptionPane.showMessageDialog(null, "Permission granted to '" + ip + "' !");

            } catch (Exception ex) {
                ex.printStackTrace();
                JOptionPane.showMessageDialog(null, "Failed");
            }
    }    
}
Re: in Python
 
0
 

This seems to be working

>>> url = urllib2.urlopen('http://www.python.org')
>>> soup = BeautifulSoup(url)
>>> srcs = [img['src'] for img in soup.find_all('img')]
>>> srcs
['/static/img/python-logo.png']
>>>
Re: in Python
 
0
 
from bs4 import BeautifulSoup
import urllib2

html = '''
<img src="smiley.gif" alt="Smiley face" height="42" width="42">'''

soup = BeautifulSoup(html)
images = soup.find('img')
print(images['src']) #smiley.gif
in VB.NET
 
0
 

hi
i'm struggling to read data from database
i created a table with 5 rows as for Login form
username and password
i would like to have access to forms when i enter password and username of department 1
it shows department 1 but when i enter password and username for department 2 it still showing department 1
i need help!!!!!!

here is my code

Imports System.Data.SqlClient

Public Class Frmlogin

Private Sub BtnLogin_Click(sender As Object, e As EventArgs) Handles BtnLogin.Click
Dim con As New SqlConnection
Dim cmd As New SqlCommand
Dim dr As SqlDataReader

con.ConnectionString = "Data Source=OCHO_CINCO;Initial Catalog=CGHMS;Integrated Security=True"
cmd.Connection = con
con.Open()
cmd.CommandText = "select log_username, log_password from login where log_username = '" & TxtUsername.Text & "' and log_password='" & Txtpassword.Text & "'"
dr = cmd.ExecuteReader

If dr.HasRows Then
MessageBox.Show("Ekurhuleni")
FrmDashBoardMenuDept1.Show()
Me.Hide()

ElseIf dr.HasRows Then
MessageBox.Show("West Rand")
FrmDashBoardMenuDept2.Show()
Me.Hide()

Else
MessageBox.Show("Invalid Username and Password")

End If
con.Close()

in Visual Basic 4 / 5 / 6
 
0
 

Hello VB Masters,

Firstly, apologize if my question is in the wrong place :)

I would like to create a loop that will copy a data from rows in the first sheet to the columns in the second sheet.

The data in the Sheet1 looks as follows:

A B C D E
F G H I J
K L M N O

And it needs to be:

A F K
B G L
C H M
D I N
E J O
A F K
B G L
C H M
D I N
E J O

(Etc.)

I am new to the topic so I am struggling with this loop.

So far I discovered that I can use some code as below. Of course, I have recorded this macro in Excel and checked the code.

Sheets("Sheet1").Select
    Range("A1:E1").Select
    Selection.Copy
    Sheets("Sheet2").Select
    Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
        False, Transpose:=True
Sheets("Sheet1").Select
    Range("A2:E2").Select
    Selection.Copy
    Sheets("Sheet2").Select
    Range("B1").Select
    Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
        False, Transpose:=True

Row A B C D E from the Sheet1 contains headers of the table and the loop should end if it reaches blank cell at the end of Sheet1.

Could you please help me with this matter and offer some guidance?

Thank you!

OP Kudos: in Python
 
0
 

Hello.
This is my code:

from bs4 import BeautifulSoup
import urllib2

url = urllib2.urlopen('http://www.website_address.com')
soup = BeautifulSoup(url)
images = soup.find_all('img')

Now how can I get the "src" of img tags?

Re: in VB.NET
 
0
 

Sorry, I thought I'm in a c# thread.. :)

Dim exdata As String() = {"98321 12345 67890 54321 09876", "89123 51234 06789 15432 60987"}
        For Each value As String In exdata
            DataGridView1.Rows.Add(value.Substring(0, value.Length - 27), value.Substring(2, value.Length - 26), value.Substring(12, value.Length - 28), value.Substring(13, value.Length - 26))
        Next

Hardz

Software Development Tag Cloud