|
Okay. Thank You
|
|
|
|
|
Member 10388494 wrote: Here is one of them. That "many ways don't work" means little; I'd be more interested in what you mean if you say that *this* version doesn't work -
Does it throw an exception? Does it insert the record or not?
Member 10388494 wrote: Violation of PRIMARY KEY constraint 'PK_StudentInfo'. Cannot insert duplicate key in object 'dbo.StudentInfo'. Sounds like you're inserting the same record twice.
Member 10388494 wrote: <layer>but i am sure 100% that there is no record that have the same code. What fields are named in "PK_StudentInfo"? How are you sure that the record isn't in there? Can you delete everything in there and see if it saves the record once?
How does your update-statement look?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
The reason that it isn't working is because you have created a primary key in your table, but because you haven't actually specified a value for it, you are attempting to insert 0 into it (assuming it's of type int). What you need to do is open up the table definition and convert this field into an identity column, and let the database take care of this for you. Alternatively, you can be really cool and convert that column to a type that supports Guids, and assign your own unique value in code.
|
|
|
|
|
Hello. how can i store a radiobutton in sql?
i have RDFemale fro a female and RDMale fro a male.
i tried this:
_cn.Open()
Dim sqlstring As String = "Insert into Student values('" & txtCode.Text & "', '" & txtName.Text & "', '" & RDFemale.value & "', '" & cmbPosition.Text & "','" & cmbTitle.Text & "', '" & txtPhoneNumber.Text & "', '" & txtAddress.Text & "','" & DateTimePicker1.Value & "',' " & cmbPmode.Text & "', '" & txtRemarks.Text & "');"
Dim _cmd As New SqlCommand(sqlstring, _cn)
_cmd.ExecuteNonQuery()
_cn.Close()
MsgBox("Record saved!!", MsgBoxStyle.Information, "Successfully saved")
End Sub
|
|
|
|
|
You can't store it directly. Since you are referring to a RDMale and a RDFemale I'd recommend you to store it as an enum.
This enum may look like that:
enum Gender{
Male,
Female
};
Afterwards you are able to store the value into a database like a normal enum, you only have to parse it to a numeric value before you store it.
|
|
|
|
|
You would store the result of the radio button as either an int or a bit (assuming that you are using SQL Server).
i.e.
dim Male as boolean = RDMale.checked
if you test that line in your application you will see that it will return true if you have checked that button or false if you haven't
Also I would have a look at using SQLParameters as this will save you from SQL Injection have a look at this StackOverflow question the actual question will show you how to set it up in VB.NET
http://stackoverflow.com/questions/16765837/set-sqlparameter-in-vb-net[^]
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Let me Explain about the entire structure of what we are doing before start ask the question
Our client required Custom Primary keys for all our transactions. To create the key, we are using store procedure which require an input parameter named "SiteCode". This store procedure will create sequence keys for every transaction in the application we have made
Every transaction insert we have written a Stored procedure and inside this sp's we have call the key generating SP before we do insert statements and we have given those key as a primary key to the insert statement. So the actual "SiteCode" input parameter has passed to every transaction SP's as an input parameter
We have created DB first entity Model and all the entity class has been created
Now We have a screen in WPF which capture the data for the models Customer, Address, Contact information.
so Instead of getting model one by one and do save changes. we would like to map the stored procedure function (used to insert the values) with respective model
for example CutomerRef attribute to sp_CreateCustomer SP in entity framework
While we are doing this mapping we can mapp all the fields except the "SiteCode" field which don't have reference in any entity model.
We have tried to create partial class to the cutomerRef model and add this property in to that partial class and try to map with SP it doesn't work Also, tried to create the field in the model itself in entity model and map with the sp parameters also not working.
We know, we can do this to call sps from stored procedure but we need them to do just by Context.Customer.Add(customerModel)
Any help would be appriciated
Regards,
Ansari
|
|
|
|
|
Hi,
I know that this question also relates to Excel but I wanted to know if there's a way or if somebody can direct me how can I access a PowerPivot table in Excel and manipulate it i.e. update data, save data, retrieve data etc'.
Basically my purpose is to interact with the PowerPivot table so I can display the data and update it from a web browser.
Avi
|
|
|
|
|
Try and give this[^] a go.
|
|
|
|
|
Thanks! It looks good.
I'll check it out.
|
|
|
|
|
i wanna new features about 2008,2010 and 2012 its urgent please ...........mail me vsateesh.mca@gmail.com or call me 9014470340
Thanks And Regards
v sateesh
9014470340
|
|
|
|
|
|
And you like spam, don't you?
Now everyone knows your email address, and even your phone number. What a good invitation to spammers!
|
|
|
|
|
There will be tons of information available on msdn and on the internet.
No one but spammers will respond to you if you give your email id out on a public forum.
|
|
|
|
|
|
SateeshVankayala wrote: urgent please
Urgent for you, not to anyone else.
And you seriously think people will draft an email or call you to provide you with the information you need? If this is your attitude towards learning, I'm sure you wouldn't learn anything in your life.
|
|
|
|
|
In keypress event the character which i press should come after my input which i send using send keys.
here is the code
if asc(e.keychar)=102 then 'ascii value of "f"
system.windows.forms.sendkeys.send("A")
end if
"f" should come after "A",but it is displaying as "fA"
How to solve this guys....
|
|
|
|
|
|
You can set the SuppressKeyPress property of the KeyEventArgs supplied in your event handler to true and then pass on both A and F in the SendKeys.
|
|
|
|
|
Hi,
I have created a custom addIn for outlook 2007 using VS2010.
I have created a custom Ribbon using xml containing a single toggleButton control. This is for new message screen. After clicking the "New Mail Message" from outlook custom ribbon visible along with the toggle button. Once I pressed the toggle button and sent the mail the toggle button remains same (on press) for every new message later. Can anybody please help me how to make toggleButton getPressed status to unchecked for every new mail message click event.
Thanks.
|
|
|
|
|
Why are you even using a toggle button? Why not a normal button??
|
|
|
|
|
byte b1 = 4;
byte b2 = 2;
byte result = b1 - b2 //error here Cannot explicitly convert type 'int' to 'byte'. Are you missing a cast?
Question is : where does the compiler see the 'int' here, where all variables are byte?
|
|
|
|
|
It is a feature of C#. The byte variables are widened to integers before performing the subtraction. Hence, the result is an integer. You can prove this to yourself with this:
object o = b1 - b2;
MessageBox.Show("o is a: " + o.GetType().FullName); So to get rid of that nasty error:
byte result =(byte)(b1 - b2); See: Why do operations on "byte" result in "int"?[^] for an explanation of why this was done.
|
|
|
|
|
|
Guys i am designing a editor,and in this editor i am using keypress event to block the pressed key and adding my input key to the text box.While adding the characters the scroll bar is automatically moving to the top of the page
i have used "textbox1.scrollcaret" also but it is always making the cursor line to be a last line.
Example
after few lines have been entered
if i add
if asc(e.keychar)=102 'For "f" ascii value of f is 102
e.handled =true
textbox1.text=textbox1.text + "c"
end if
How to solve this problem guys....
|
|
|
|