Nice Eric!
john nada
Posts
-
Inserting lots of rows programmatically -
Inserting lots of rows programmaticallyHere's a way to populate the PostalCode column. I would set the default value of the columns CountryCode and WarehouseNum to 1 instead of explictly inserting the value 1 each time.
DECLARE @PostalCode varchar(10) DECLARE @Number int SET @Number = 0 WHILE @Number < 100000 BEGIN /* Format PostalCode */ IF LEN(@Number) = 1 BEGIN SET @PostalCode = '0000' + CAST(@Number AS varchar) END ELSE IF LEN(@Number) = 2 BEGIN SET @PostalCode = '000' + CAST(@Number AS varchar) END ELSE IF LEN(@Number) = 3 BEGIN SET @PostalCode = '00' + CAST(@Number AS varchar) END ELSE IF LEN(@Number) = 4 BEGIN SET @PostalCode = '0' + CAST(@Number AS varchar) END ELSE IF LEN(@Number) = 5 BEGIN SET @PostalCode = CAST(@Number AS varchar) END /* Insert PostalCode */ INSERT INTO Wzip_Detail(PostalCode) VALUES(@PostalCode) /* Increment number */ SET @Number = @Number + 1 END
-
Attach file and send it as an emailI don't know what to do exactly without trying it myself, but maybe this can get you started in the right direction.. To upload a file put a file field on your form: When the page is posted back to the server you can access the uploaded file by calling the PostedFile property of the file field: fileUpload.PostedFile Use the InputStream property of the PostedFile to do whatever you have to, for example: Dim img As System.Drawing.Image img = img.FromStream(fileUpload.PostedFile.InputStream) Create the email: Dim email as New System.Web.Mail.MailMessage email.Attachements.Add(img) email.From = "from@hotmail.com" email.To = "to@hotmail.com" email.Subject = "test" email.Body = "hi" Send the email (make sure the Smtp service is running in your IIS server): SmtpMail.Send(email)
-
How to Execute sql script in vb.net' Create a stream to read the sql file Dim reader As StreamReader = New StreamReader(path) ' Read the contents of the file into a string variable Dim sqlScript as String = reader.ReadToEnd() ' Execute the sql on the database Dim command as New SqlCommand(sqlScript, New SqlConnection(connStr)) command.ExecuteNonQuery()