ABAboi's Posts
Nairaland Forum › ABAboi's Profile › ABAboi's Posts
Omosilade:other ways you can modify the code includes searching and displaying an image using the values of a textbox. The second part of the code is to display the image from the database (assuming that you have actually created the imageData table and contain values). You will need picturebox, image1, textbox , textbox1 then under the button to display the image :: 'Read an image Using conn As New System.Data.SqlClient.SqlConnection("[s]Data Source=DENSMAN-PC\SQLEXPRESS;Initial Catalog=aba;Integrated Security=True[/s]" 'insert ur connection stringconn.Open() Using cmd As New SqlClient.SqlCommand("Select Name, CreateDate, Picture From ImageData", conn) Using dr As SqlClient.SqlDataReader = cmd.ExecuteReader() Using dt As New DataTable dt.Load(dr) Dim row As DataRow = dt.Rows(0) Dim sName As String = Convert.ToString(row("Name" )Dim dtCreateDate As DateTime = Convert.ToDateTime(row("CreateDate" )Using ms As New IO.MemoryStream(CType(row("Picture" , Byte()))Dim img As Image = Image.FromStream(ms) Image1.Image = img End Using TextBox1.Text = ("Loaded image " + sName) End Using End Using End Using End Using Goodluck try it and if not working reply and show ur error. Else notify when it is working End Sub |
Thanks guys for your inputs. I managed to do it. I used to a while loop to read the column(Access Level which happens to be the third column) while authenticating the user. The sample code below was wat i did. Once again thanks If theReader.HasRows Then 'we have data, user exists success = True End If While theReader.Read authorityReader = theReader(2) End While |
webdezzi:Thanks for your input. Those checks based on a preset privilege is what i want to know. I thought about creating a column called Authority in the table, then assigning them with number eg gardener =1, Manager = 2, But i need other ideas on how to make it work better |
Paroh_frey:I am able to authenticate all the staff ID thats not the issue. For instance, i need to show form1 if the gardener is logged in, form2 if manager is logged etc. Beaf:The code was quite helpful thanks. But i am using VB not ASP as the program is not web based. |
Hello guys, am working on a staff management program(using VB.NET and SQLSERVER) that requires workers with different authorities to access the system. For Instance, a gardener and Manager will log in to the system using a unique staff ID. What is your idea on how to differentiate between the users when they log in??
|
Its actually a straight forward process. Follow the following steps. However the following codes basically scans ur computer for .JPEG file extensions and adds them direct to ur SQLSERVER. But ofcourse u can decide to import the image in a picture box control prior saving it in the database. Create a table named "ImageData"Its attributess are Name (varChar50) Picture (Image) CreateDate(varChar20)--'NOT REALLY NECCESSARY Now in your Form, You will need 2 buttons named btnSave and BtnSearch, textbox (txtName) For the clicked event of btnSearch, add these codes Dim pictureLocation As String Dim a As New OpenFileDialog a.Filter = ("Image files| *.JPG" ![]() pictureLocation = a.FileName a.ShowDialog() Using conn As New System.Data.SqlClient.SqlConnection("[s]Data Source=DENSMAN-PC\SQLEXPRESS;Initial Catalog=aba;Integrated Security=True[/s]" 'Insert ur connection string hereconn.Open() Using cmd As New SqlClient.SqlCommand("Insert Into ImageData(Name, CreateDate, Picture) Values (@Name, @CreateDate, @Picture)", conn) cmd.Parameters.Add(New SqlClient.SqlParameter("@Name", SqlDbType.VarChar)).Value = txtName.Text cmd.Parameters.Add(New SqlClient.SqlParameter("@CreateDate", SqlDbType.VarChar)).Value = DateTime.Today cmd.Parameters.Add(New SqlClient.SqlParameter("@Picture", SqlDbType.Image)).Value = IO.File.ReadAllBytes(a.FileName) cmd.ExecuteNonQuery() End Using End Using When you are done with the following, i can tell u other ways to modify and optimise your programme, then i will give u the second part once u get this working. Cheers |
Hello guys, I am new here and love the great and quality interaction going on here. Please i am a Nigerian IT software developer based in UK, i want to develop programmes(softwares) that is not readily available in Nigeria. Please i would like you to help me list the most needed IT programmes in Nigeria. The one's i have in mind includes; 1. Motor vehicle reg system and mgt for FRSC (federal road safety corps) 2. Mobile banking 3. Computerised birth registration system 4. Transportation tracking system (to manage time and duration of buses in cities) Please i need your opinion thanks |
'insert ur connection string