|
How do i save images into a database if i don't want to use the path name of the image
|
|
|
|
|
convert the image into the byte array using memory stream and store in the database.
Regards
Azeem
|
|
|
|
|
Hi,
Here is the procedure for saving the image to the DataBase using SQL Server:
1. Get the content length of the image that is to be uploaded
2. Create a byte[] to store the image
3. Read the input stream of the posted file
4. Create a connection object
5. Open the connection object
6. Create a command object
7. Add parameters to the command object
8. Execute the sql command using the ExecuteNonQuery method of the command object
9. Close the connection object.
You may refer to this[^] article for more information on this.
Hope this helps.
Vinay
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
Hi,
I'm looking for Gantt chart Control/ActiveX in VB.NET for developing a software.
Thanks to all great programmer that help me to find a free control and also powerful control for TaskScheduling.
Iman,
<attarzadeh.std@gmail.com>
|
|
|
|
|
|
In XL, if you hide a sheet (or sheets) in a workbook, it means the USER cannot see them, but does it mean the macros and Forms can't see them as well?
I am running a purchase order system, and want the data tables to be unseen by other users, they access only the PO itself and the Index List, but as soon as I hide the sheets, BANG, lots of crashes!
I don't know what to do, except leave the sheets visible.
Any suggestions?
------------------------------------
"I want you to imagine I have a blaster in my hand" - Zaphod Beeblebrox.
"You DO have a blaster in your hand" - Freighter Pilot
"Yeah, so you don't have to tax your imagination too hard" - Zaphod Beeblebrox
|
|
|
|
|
The sheets are all available to your macro... check that you are not referencing ActiveSheet - substitute with Sheets("SheetName").
HTH
|
|
|
|
|
I got a vb service that does not want to do IO. It works fine in my test environment but when I deploy it, it doesn't seem to want to do the IO part of its task. Does anybody know why?
Stephen Lintott Bsc IT (RAU)
|
|
|
|
|
This may seem a little obvious, but without the code in front of me, well...
Are you declaring System.IO within the code?
I ask only because I was caught out on this before!
------------------------------------
"I want you to imagine I have a blaster in my hand" - Zaphod Beeblebrox.
"You DO have a blaster in your hand" - Freighter Pilot
"Yeah, so you don't have to tax your imagination too hard" - Zaphod Beeblebrox
|
|
|
|
|
Sorry never thought about the code...
The answer is yes and here is some code to go with it.
Dim sw As New System.IO.StreamWriter(ConfigurationManager.AppSettings("IPAccountingLocation") & routerIP & ".txt")
Try
sw.Write(result)
Catch ex As Exception
Finally
sw.Close()
sw.Dispose()
End Try
Try
Dim path As String
path = ConfigurationManager.AppSettings("AppServer")
Dim CurrentDate = DateTime.Now
path = path + "\" + CurrentDate.year.ToString
Dim DateStr = ""
If CurrentDate.Month.ToString = "1" Then
DateStr = "Jan"
End If
If CurrentDate.Month.ToString = "2" Then
DateStr = "Feb"
End If
If CurrentDate.Month.ToString = "3" Then
DateStr = "Mrt"
End If
If CurrentDate.Month.ToString = "4" Then
DateStr = "Apr"
End If
If CurrentDate.Month.ToString = "5" Then
DateStr = "May"
End If
If CurrentDate.Month.ToString = "6" Then
DateStr = "Jun"
End If
If CurrentDate.Month.ToString = "7" Then
DateStr = "Jul"
End If
If CurrentDate.Month.ToString = "8" Then
DateStr = "Aug"
End If
If CurrentDate.Month.ToString = "9" Then
DateStr = "Sep"
End If
If CurrentDate.Month.ToString = "10" Then
DateStr = "Oct"
End If
If CurrentDate.Month.ToString = "11" Then
DateStr = "Nov"
End If
If CurrentDate.Month.ToString = "12" Then
DateStr = "Dec"
End If
path = path + "\" + DateStr
Dim strRouterName As String = ""
' Just to get the router name
Dim con As New SqlClient.SqlConnection(ConfigurationManager.AppSettings("SQLConn"))
con.Open()
Dim selectName As New SqlClient.SqlCommand("Select RouterName from tblRouters where RouterIP=@RouterIP;", con)
Dim sqlParam As New SqlClient.SqlParameter("@RouterIP", SqlDbType.NVarChar)
sqlParam.Value = routerIP
selectName.Parameters.Add(sqlParam)
Dim sqlReader As SqlClient.SqlDataReader
sqlReader = selectName.ExecuteReader
If sqlReader.Read Then
strRouterName = sqlReader("RouterName")
End If
sqlReader.Close()
con.Close()
path = path + "\" + routerIP + "-" + strRouterName
path = path + "\" + CurrentDate.Day.ToString
Dim dir As New System.IO.DirectoryInfo(path)
dir.Create()
path = path + "\" + routerIP + "-" + CurrentDate.Hour.ToString + "-" + CurrentDate.Minute.ToString + ".txt"
Dim sw1 As New System.IO.StreamWriter(path)
sw1.Write(result)
sw1.Close()
sw1.Dispose()
Stephen Lintott Bsc IT (RAU)
|
|
|
|
|
I have read through twice, and can't see why the io isn't working.
The paths seem clear enough (A little convoluted but readable), and the io definately declared correctly.
What appears to be the problem when running? is it just not opening the streams?
------------------------------------
"I want you to imagine I have a blaster in my hand" - Zaphod Beeblebrox.
"You DO have a blaster in your hand" - Freighter Pilot
"Yeah, so you don't have to tax your imagination too hard" - Zaphod Beeblebrox
|
|
|
|
|
As I said. It works fine in the test environment but does nothing in the live environment. No directory creatition, no files nothing
Stephen Lintott Bsc IT (RAU)
|
|
|
|
|
One quick solution...
Check all the Read/Write/Execute all permissions are applicable for creation/modification/deletion of Folder/File on the server that you are trying to connect to!!!
Regards,
ZAK
|
|
|
|
|
It's running on the server a a local service and is doing io to the local drives. What settings must I check? I'm not connecting to a server with this.
Stephen Lintott Bsc IT (RAU)
|
|
|
|
|
I am trying to populate a table in a strongly typed dataset used for the ReportViewer.
I want to read in an XML file which was created manually using ds.WriteXML.
The strongly typed dataset has been created to match the structure of the XML file written with ds.WriteXML.
How do I read in the XML file, and populate the table within the dataset used for the ReportViewer?
|
|
|
|
|
oDS.ReadXml(sfilename)
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
PL SUGGEST ME HOW CAN IN INSERT DATETIMEPICKER IN A DATAGRIDVIEW IN VB.NET
THANKS
rmshah
Developer
|
|
|
|
|
you can see a sample here[^]
Il principe
|
|
|
|
|
ya i tried the one you shown it's working fine to me!! thanks mate
ZAK
|
|
|
|
|
For Each row As DataGridViewRow In DataGridView1.Rows
row.Cells("Date").Value = Today
Next
|
|
|
|
|
Please anybody there...know how to detect if a removable storage device is write protected?? i having difficulty to figure this out.. Please help?...
i do really appreciate to anybody share their idea... please.. thanks in advance...
|
|
|
|
|
You could aways try to write a temporary file to it and catch the exception if the device is write-protected.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I have a project where a Teacher can choose their class from a ComboBox and this is turn selects all the relevant student from an Access Database and displays this along with some extra columns in a DataGridView.
The Teacher can then add 'Penalty Points' and 'Demerits' to the student before saving them to a spreadsheet (reason being the info needs a lot of formulas to get it to work out several thing the Heads of Year want to see!). I can Insert into Excel using code such as:
Imports System.Data
Public Class Form1
Private Sub cmdSave_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles cmdSave.Click
Try
Dim MyConnection As System.Data.OleDb.OleDbConnection
Dim myCommand As New System.Data.OleDb.OleDbCommand
Dim sql As String
MyConnection = New System.Data.OleDb.OleDbConnection _
("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + _
"'S:\Penalty Points\07-08\Test.xls;Extended Properties=""Excel 8.0;HDR=Yes;IMEX=0""")
MyConnection.Open()
myCommand.Connection = MyConnection
sql = "Insert into [Sheet1$] (StudentId,Name) values('5','e')"
myCommand.CommandText = sql
myCommand.ExecuteNonQuery()
MyConnection.Close()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
MsgBox("Row Added Successfully")
End Sub
End Class
But I need to loop through the DatagridView, Inserting all rows that have been ammended. Can anyone help me out please?
Thanks in Advance
|
|
|
|
|
Here's my latest code:
Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
Try
Dim MyExcelConnection As System.Data.OleDb.OleDbConnection
Dim myCommand As New System.Data.OleDb.OleDbCommand
Dim daExcel As New System.Data.OleDb.OleDbDataAdapter
MyExcelConnection = New System.Data.OleDb.OleDbConnection _
("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=S:\SanctionsDb\2007-08\points.xls;Extended Properties=""Excel 8.0;HDR=Yes;IMEX=0""")
For Each row As DataGridViewRow In DataGridView1.Rows
With myCommand
.CommandText = "Insert into [Sheet1$] (StudentId,StuName,ClassGrp,TheDate,Merits,Demerits,Lesson," + _
"TeachingGrp,Description,Action,MeritType) values(?,?,?,?,?,?,?,?,?,?,?)"
.CommandType = CommandType.Text
.Connection = MyConnection
' Configure the insert parameters
.Parameters.Add(New OleDb.OleDbParameter("StudId", OleDb.OleDbType.Double, 0, "StudId"))
.Parameters.Add(New OleDb.OleDbParameter("Name", OleDb.OleDbType.Double, 0, "Name"))
.Parameters.Add(New OleDb.OleDbParameter("Class Grp", OleDb.OleDbType.Double, 0, "ClassGrp"))
.Parameters.Add(New OleDb.OleDbParameter("Date", OleDb.OleDbType.Double, 0, "Date"))
.Parameters.Add(New OleDb.OleDbParameter("Merits to Add", OleDb.OleDbType.Double, 0, "Merits"))
.Parameters.Add(New OleDb.OleDbParameter("Demerits to Add", OleDb.OleDbType.Double, 0, "Demerits"))
.Parameters.Add(New OleDb.OleDbParameter("Lesson", OleDb.OleDbType.Double, 0, "Lesson"))
.Parameters.Add(New OleDb.OleDbParameter("TeachingGrp", OleDb.OleDbType.Double, 0, "TeachingGrp"))
.Parameters.Add(New OleDb.OleDbParameter("Description", OleDb.OleDbType.Double, 0, "Description"))
.Parameters.Add(New OleDb.OleDbParameter("Action", OleDb.OleDbType.Double, 0, "Action"))
.Parameters.Add(New OleDb.OleDbParameter("Type", OleDb.OleDbType.Double, 0, "Type"))
End With
Next
daExcel.InsertCommand = myCommand
MyExcelConnection.Open()
daExcel.Update(ds, "Groups")
' Cleanup
MyExcelConnection.Close()
daExcel.Dispose()
daExcel = Nothing
MyExcelConnection.Dispose()
MyExcelConnection = Nothing
Catch ex As Exception
MsgBox(ex.ToString)
End Try
MsgBox("Row Added ")
End Sub
Surely it should work shouldn't it?
|
|
|
|
|
I am filling combo box as per below code,and i want to insert the respectibe selected item's code from the database into other table.
how to get selected value?
My code for filling combo box is..
dbconn = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=C:\guest\dmb.mdb")
dbconn.Open()
sql = "Select distinct DESIGNATION from DESIG"
dbcomm = New OleDb.OleDbCommand(sql, dbconn)
dbread = dbcomm.Executereader()
cmbdesig.Items.Clear()
While dbread.Read
cmbdesig.Items.Add(dbread("DESIGNATION"))
End While
dbread.close()
dbconn.Close()
Designation table have both desig_code and designation.
I want to get the selected value (desig_code).Which property should i set to get it??
Answer please
kissy
|
|
|
|