Sql Server - Saving A New Object With An Empty PetaPoco Fails To Do An Insert?

Jan 16, 2012

I am trying to save a new object to the database using petapoco.I have an object that uses a Guid for the primary key.Here is an example of the objects primary key property.

<PetaPoco.Column()> _
Public ReadOnly Property Primkey() As Guid Implements IStandardDocument.Primkey
Get

[code]....

Here is an example of the save method.

database.Save("Reservations", "Primkey", reservation)

The sql that is generated is an update with a primkey of 00000000-0000-0000-0000-000000000000 instead of an insert. So new records are never inserted.If I have an existing object with a valid guid the update and delete all work correctly.

View 3 Replies


ADVERTISEMENT

Asp.net - Filehelpers ExcelStorage.ExtractRecords Fails When First Cell Is Empty

Sep 22, 2009

When the first cell of an excel sheet to import using ExcelStorage.ExtractRecords is empty, the process fail. Ie. If the data starts at col 1, row 2, if the cell (2,1) has an empty value, the method fails.

how to work-around this? I've tried adding a FieldNullValue attribute to the mapping class with no luck.

Here is a sample project that show the code with problems

View 3 Replies

VS 2008 SQL Database Insert/Update Fails?

Jun 8, 2009

I have made a small form where I have bound textbox with records from database.Although my code for inserting and updating the record seems fine and working. But when I view the database, tables i see no inserts/updates made there. But When I run my application again, I see the records in the bound textbox but only for some seconds (for around 1 and half minutes), although they are not shown in the database (tables) actually.

When I close the application and run again it after 1-2 minutes there are no more records bound to the textbox, since no records at all.How can this be possible. I don't have any idea what's going on.

I have been using visual studio 2008 and sql server.Code I have been using for ::

'Update the Records Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click

[Code]...

View 2 Replies

Insert Pop Up Error If Connection Drops Or Download Fails

Feb 7, 2011

I built a dwonloader program which download a file from the web. I would like to insert an error message that pop up whenever the program fail to download the file and/or when the computer gets disconnected from the internet while the program is downloading the file.

View 12 Replies

AsyncFileUpload Fails On The Server?

Mar 7, 2011

I am currently using the AsyncFileUpload in my VB.NET web app. Locally it works perfectly, however on the server it fails to upload a small file (<9k). I can't even seem to debug this as in JavaScript handlers I have no idea as to how to get the error reason.

function uploadError(sender,args) {
$get("<%=LabelErr.ClientID%>").innerHTML = "Unable to Upload file for the following reason: ", "<span style='color:red;'>" + args.get_errorMessage() + "</span>";

[code].....

View 1 Replies

Referencing An Object (class) Within A Thread Fails

Jun 8, 2012

Referencing an object (class) within a thread fails

I have an object ("a vb class") that needs to run on a separate thread and communicate with the U/I.

Even using sample code, I cannot get the object to run within a thread. I demonstrate this problem with two examples. The first calls a function within the form and it works perfectly. The second creates an object and performs the same calls, but fails.

example #1 [working] (Called within a form)
Private Delegate Sub FuctionToBeRunInThreadDelegate
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

[Code]....

SUMMARY: When the thread creates the object, it appears that the object is not actually running inside of a thread or else form.InvokeRequired would be true. I have other more complex examples where this is strongly verified and evidenced, but I provided these two as a very simple demonstration of my problem.How can I have a thread "own" a series of individual objects so that the objects are run asynchronously and can independently report back to the U/I?

View 1 Replies

Fails POSTing Data To Web Server

Apr 22, 2011

[code]...

web server was sending a HTTP/1.1 302 Found instead of HTTP/1.1 200 OK

View 2 Replies

TCP / IP Server - Remote Connection Fails To Connect

Mar 27, 2009

I've came across a little problem with my tcp / ip server. My client can connect to it with 127.0.0.1 ( localhost ), and 192.168.0.X, but every remote connection fails to connect.

Here's the connection rituals:
Server
listener = New System.Net.Sockets.TcpListener(System.Net.IPAddress.Any, Port)
listener.Start()
listenThread = New System.Threading.Thread(AddressOf doListen)
listenThread.IsBackground = True
listenThread.Start()

Client
client = New System.Net.Sockets.TcpClient(IP, Port)
client.GetStream.BeginRead(readBuffer, 0, BYTES_TO_READ, AddressOf DoRead, Nothing)

View 7 Replies

Serialization Fails Because A Form Is Handling A Custom Object's Event

Aug 12, 2009

My application's binary serialization was working well up to today (this is not a released app yet - still in development). I have a "Project" class that is the top-level class of a hierarchy of other classes related to its function. And before you think it, yes, all of those classes are marked as serializable. Infact, they all were being serialized before today.

I have one event on the Project class that assists in informing when the project's save status has changed (i.e. new, modified, saved). This event was added today along with some events on the other classes that filter up to the Project class (the project needs to be told when its objects have been modified). I unfortunately added all of this at the same time so I can't provide any incremental details as to when it stopped working, but when I try to save the project through my binary formatter it tells me that my main form is not marked as serializable. Well, yeah... of course it isn't! it shouldn't need to be because there is no member of my classes that even mentions the form. But for some reason handling the Project's event on the form triggers this error.

Serializing the form is not a solution. Neither is not being able to handle my Project events. If I comment out the handler it works fine -- and I don't even have to remove the WithEvents keyword on my form's Project variable. Now that I write that I'm speculating that it may have to do with the event being raised as a result of the serialization (occurs when the save button is clicked).

View 7 Replies

Checking If Dynamic Text Boxes Are Empty/ No Input When Saving?

Aug 8, 2011

For example, I clicked the Add Text box button, so it added 3 text boxes in the form (I used Dynamic text box so it can add multiple text box). When I input data to one of those 3 text boxes and then Save button has been clicked. It should checked whether the dynamic text boxes are empty or not. If there are empty text boxes, then saving data to db should not be continued and display a message telling the user that empty field(s) are invalid.

In the code below, it saves the data even if there are empty text boxes and I think because it is in the for loop, it checks the text boxes one by one and repeatedly displays the message box that I coded.

Here's the complete code:

Imports System.Data
Imports System.Data.SqlClient
Public Class Form3

[Code]....

View 5 Replies

Loop Through Text Boxes To Check If They Are Empty Before Saving Recor?

Nov 16, 2010

I have an insert statement which works fine but before the record is saved I want to validate the text boxes. So I just need to know how to check for empty text boxes before the save button is clicked on. I have seen a couple of examples like:

Dim ctr As TextBox
If ctr.Text = vbNullString Then
MsgBox("empty box")

[code].....

View 11 Replies

If DDL Statement Fails Whole Transaction Is Rolled Back Sql Server?

Mar 24, 2009

I have a series of DML and DDL(Drop View only) statements that I need to execute under single transaction from VB.net app. I m using commandObj, and kept above all I kept beginTransaction statement. Everything is working fine expect when error is returned by Drop statement. If Drop statement returns error then whole transaction is rolledback. I do not want tthis. I want to continue even if Drop fails keeping the other DML statements that were executed before Drop.

View 5 Replies

Check If Session Item Exists Fails Itself With Object Reference Not Set Error

Aug 12, 2011

I'm having problem regarding session items. Before I use them, I want to check if they exists, but using this codes gives me error:[code]I think Session("SomeSessionItem") tries to acquire the value of the session item. If the item doesn't exists then it throws exception. But how do I check if a session item exists before using them? I have a page Home.aspx.In the Home.aspx.vb, I instantiate a WebUserControl SomeControl.ascx. Note that in Home.aspx.vb event handler Page_Load I can use a condition to check session without getting an exception.Inside SomeControl.ascx.vb I'm trying to access the session, here's where the exception occurs.

View 5 Replies

Iterate Through Class / Object Properties - Saving Them Each To Another Object

Dec 15, 2011

I'd like to have something like:

[Code]...

View 1 Replies

Asp.net - Open A FormView In Insert Mode Only When It's Empty

Apr 2, 2012

I have a FormView which I would like to open in insert mode only if the form contains no data. I've tried the following if statement:

If True Then
If SomeFormView.DataItemCount = 0 Then
SomeFormView.ChangeMode(FormViewMode.Insert)

[Code]....

but it opens in insert whether empty or not?

View 1 Replies

Sql Server - SSIS - Killing Excel.exe When Data Flow Task Fails?

May 10, 2012

How can I kill the excel.exe process in SSIS during the data flow task when it fails? There could be multiple instances of Excel.exe running from other packages that are perfectly valid so I don't want to loop through all instances killing them.My problem is that during the data flow task the process will sometimes fail due to a sheet that is named incorrectly or missing columns. This keeps an instance of excel.exe running which is now an orphan task eating up resources so it needs to be killed.At the same time there are other SSIS packages running that are accessing their own excel.exe process and aren't having any issues. So how can I kill the orphan excel.exe process without impacting the other excel.exe process?

View 2 Replies

Insert NULL Into Database If Form Field Is Empty Using ASP.NET & VB?

Jan 18, 2011

I have a form and stored procedure that inserts the data from the form. It works fine except that if a field isn't filled in it doesn't insert a NULL into SQL it inserts "".

I've tried a few different ways but none seem to insert NULL, the one below still inserts "", can anyone point me in the right direction?

Here is the required part of the code, if you require more just let me know.

Dim rdr As SqlDataReader
Dim cmdInsert As SqlCommand = New SqlCommand()
cmdInsert.CommandText = "spPersonalDetailsInsert"

[Code].....

So if I enter nothing into address1 field it should write NULL to screen but it always writes NOT NULL. What does an empty form field equal? in classic ASP it was always "".

View 4 Replies

Asp.net - Database Connections Work Fine When Application Is Run From Localhost. Login Fails From Dev Server

Jun 11, 2009

I have an application which connects to a database, retrieves a username from a user's table and matches it against the username retrieved with System.Security.Principal.WindowsIdentity.GetCurrent.Name.On my localhost, everything works fine. The database exists on the development server but the application lies on my localhost. All of my authorization and authentication techniques are running smoothly.However, when I publish my application to the development server, I'm faced with the following error.Cannot open database requested in login 'databaseName'. Login fails.Login failed for user 'DevelopmentServerNameASPNET'.

[Code]...

View 4 Replies

Identify An Xml Empty Tag Using The XmlNodeType Object?

May 22, 2012

I have a program that analyzes and processes a complex xml data source (without a schema).The initial part of the program reads the xml line by line and captures the data value, table name and field name for further processing. The data (xml file) is created using InfoPath. This worked fine until we started using InfoPath 2010, which uses the "empty tag" (<tag />) for empty values instead of the traditional tags with no value (<tag></tag>). Of course my program does not know what to do with the empty tags and just ignores them - no exception, and no error.My question is: Does anyone know how to identify the empty tag using the XmlNodeType object attributes (in blue)?

Private Sub Process_ReportData(ByVal vFilePath As String, ByVal vFileName As String)
' Create an instance of XmlTextReader and call Read method to read the(file)
Dim RecordsTableAdapter As New RecordsTableAdapter

[code].....

View 2 Replies

Set The Column Width And Leave The Top 10 Rows Empty In Order To Insert An Image Into Excel Report?

Sep 3, 2009

How can I set the column width and leave the top 10 rows empty in order to insert an image into my Excel report?

Here is my code:

If ComDset.Tables(0).Rows.Count > 0 Then
Try
With Excel

[code]....

View 1 Replies

Insert Data To A SQL Server Compact Database Sql Server Mdf?

Feb 28, 2010

i have a app in visual basic mobile 2008, so i finish but now i need to tranfer the data generate in the in the app mobile to data base in sql server 2008.

View 1 Replies

Check Object's Property For Null Or Empty String?

Jul 28, 2009

I'm using FileHelper to generate object's property. Here is an example of one property:

<FieldOptional(), _
FieldTrim(TrimMode.Both)> _
<FieldNullValue(GetType(String), " ")> _
Public StoreNo As String

As you can see the StoreNo will either have a value or " ", one of the business policy is to check if the StoreNo is empty or nothing if the object's StoreNo is empty or null then the record will not create.

I though about creating an HasValue Function in the class to check the StoreNo and other properties in the object but I feel like it is a hack.

Public Function HasValue() As Boolean
Dim _HasValue As Boolean = True
If StringHelper.IsNullOrBlank(Me.StoreNo) Then

[Code]....

I don't think this approach is an ideal solution. what if the StoreNo is remove or change to something else. What's the best approach to check object's property?

View 3 Replies

Saving Data + .net + Sql + Insert Not Working?

Oct 10, 2011

I am trying to save data to database but I got a exception here is the code

Try 'connection is set
sqlcon = New SqlConnection("Data Source=MENUKA-PC\SQLEXPRESS;Initial Catalog=studentInformation; Integrated Security=True")
sqlcon.Open()

[code].....

View 10 Replies

Adding Then Saving A Row Into A Table Using Insert Through A Tableadaptor

Feb 3, 2010

I have 3 tables. Customer,item, and price, where price holds the customerid,itemid, and the price. This lets me set a different price for each item based on who is buying it. I am trying to add data to the price table from a form which gets a customerid and itemid, and the price they will be charged. The only table to be updated is the price table.

Private Sub SaveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveaspButton.Click
' cust and item are pulled in when the user inputs a name, the lookuptable is used to put into an unseen label

[Code]....

This does add a table in the table visual studios uses but wont save it to the main database. This means I can do a fill method and see the row while the program is running, but wont be there next time I run the program.

View 4 Replies

DB/Reporting :: INSERT INTO Statement Working But Not Saving?

May 19, 2012

I'm running into a slight problem with an SQL INSERT INTO statement. I've tried setting this up first as a command statement and now as a stored procedure. When the process runs it's not signaling any errors and it appears that it's working properly. However when I check the database nothing new has been added. I have the statement within a try catch and it's not catching any errors. I've gone so far as to delete the table and recreate it, still nothing. I should also point out that this entire statement was essentially a copy & paste from another program that's working perfectly.

vb.net code below

Code:
Try
Dim cmd As New SqlCommand
cmd.Connection = con

[code]....

View 1 Replies

Event Handler Code Cause A Object Reference Not Set To An Instance Of An Object. Error (only Present On Live Server, Ok On Dev)?

Mar 4, 2010

Here is the code for the button click event;

Protected Sub CompetenciesButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CompetenciesButton.Click
Dim con As String = WebConfigurationManager.ConnectionStrings("foo").ToString()

[code].....

View 1 Replies

Pass Dbnull Or Nothing Value To Sql Server Using Tableadapter If Textbox.text Is Empty

Aug 17, 2009

I have a form with the following on it [code]then everything works as it should (as long as there is data in the text boxes) If there is one of the text boxes is left empty then an error is returned. The text boxes are not bound and the db is set to allow nulls. Is there an easy way to suggest that if name.textbox is empty then input "nothing" or dbnull etc.I have a lot of text boxes (approx 30) and ideally dont want to write if statements for each one. But will if i have to of corse.

View 2 Replies

Intermittent Login In ASP / SQL Server 2000 - Some Times Login Fails?

Sep 16, 2009

I have an ASP application with Sql Server 2000 database. The application has a login page. It was working fine. But from past few days, some times login fails and some time it works. I looked into the procedure and ASP page but could not find any issue.

View 2 Replies

Saving A Created Object On A Picturebox?

Apr 3, 2010

I need to save a object that i programing to be drawed onto apictureboxPictureBox1.CreateGraphics().FillEllipse(Brushes.Blue, ci)how do i save the object as a image or the picturebox? And then be able to open it again?

View 7 Replies

Saving Class Object To File

May 16, 2010

I have a question about how to save a class object to a file that can be used to create a same class later. The class should contain some structure or proprties and different types of data such as Byte, String, Bitmap, Color and so on. Is there any good way to save all these things? Convert the whole class to byte or make it to XML? The only way I know is saving to XML, but I feel hard to write all types like Image, Array List in XML. Here is a part of the class:

[Code]...

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved