Programming | Computer | Tutorial | Mobile | Gaming | Fixing Errors | Yoga | Kitchen
SQL Server vs. C# Data Types
SQL data type | C# data type | |||||||||
binary, tinyint |
Byte | |||||||||
varbinary | Byte[] | |||||||||
smallint | Int16, Short | |||||||||
bigint | Int64, long | |||||||||
bit | Bool | |||||||||
int | Int32, int | |||||||||
money, smallmoney | Decimal | |||||||||
float | Double | |||||||||
decimal, numeric | Decimal | |||||||||
nchar, nvarchar | String, Char Array | |||||||||
real | Single | |||||||||
sql_variant | Object | |||||||||
time | TimeSpan | |||||||||
date | DateTime, Nullable<DateTime> | |||||||||
uniqueidentifier | Guid | |||||||||
The Datatypes C#
hasn't but SQL has
|
||||||||||
varchar | None | |||||||||
xml | None | |||||||||
image | None | |||||||||
table | None | |||||||||
timestamp | None | |||||||||
text | None | |||||||||
cursor | None |
Inserting records into a database table using a stored procedure: |
CREATE TABLE [dbo].[RegisteredClients] (
[ ClientUserName] VARCHAR (20) NOT NULL,
[MasterDistributor] VARCHAR (20) NOT NULL,);
2. Create Stored Procedure
CREATE PROCEDURE [dbo].[sp_InsertClientData]
@ClientUserName VARCHAR (20),
@MasterDistributor VARCHAR (20),
AS
Insert into RegisteredClients values
(
@ClientUserName,
@MasterDistributor,
)
RETURN 0
3. C# Code
string strConnString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
SqlConnection con = new SqlConnection(strConnString);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sp_InsertClientData";
cmd.Parameters.Add("@ClientUserName", SqlDbType.VarChar).Value = txtClientUserName.Text;
cmd.Parameters.Add("@MasterDistributor", SqlDbType.VarChar).Value = ddlMasterDistributor.SelectedItem.Value;
Please visit to our YouTube Channel for .net and other tech tutorial Thanks |
Inserting null values into database from TextBox using
StoredProcedure: 1. First you have to allow null to your column what you have created in table 2. Allow null to that column too in stored procedure parameter like this:
|
How I directly pass the checkbox value to database as a bit:
|
Connect
to LocalDB existing in App_Data Folder in ASP.net Project Solution: <connectionStrings> <add name="ConnectionName" connectionString="Data Source=(LocalDB)\MSSQLLocalDB; AttachDbFilename=|DataDirectory|DatabaseName.mdf; Integrated Security=True;" providerName="System.Data.SqlClient" /> </connectionStrings> And please don't use this (User Instance=True;) in your connection string. Use above connection string as it is, just change your connection name to as you want to name it and Data base file name to your database file name (.mdf). It will work fine, Thanks...
|
The user instance login flag is not supported:
Its a feature of SQL Server Express edition, that is why it is not supported to your SQL Edition.
Your Connection string has user Instance attribute, Remove the "User Instance=True;".
Please visit to our YouTube Channel for .net and other Tech tutorial, Thanks |
Connection String for database which exists in asp.net Project: If you have your database (.mdf) in App_Data Folder then it will work fine. <connectionStrings>
|
Button OnClick event not firing in asp.net Project:
You must be copied this method from other application. don't you? So you need to delete the event and event name assigned to the button from both of the files .cs and .aspx,
Step 1: First Change the Button name property to what you want to keep the name of click event function,
Step 2: Go to design and go to button hit F4 to open properties window.
Step 3: In event tab go to onClick event double click next to it, it will generate event and it automatically assigns event name to the button according to the name what you name it in name property.
It will work now... Thanks,
Why is Q always followed by U:
Every alphabet has its own sound as like "T" when we write Top we don't need a vowel to make sound of "e" so we write directly "Top" and the o overlap the "e" sound. But in the Tea we need two vowels separate vowel for "e" sound. The same case in q"u" when we write the, we need two vowels separate vowel for "u" sound. But when we don't need "u" sound , we can write the word like QWERTY. Conclusion is this we can't use alphabet's successor vowel sound using it in a word we write vowel for that sound.
Thank You So Much Friends
Go to HindiTechSirji for Tech Tutorial of {Word, Excel, Powerpoint, HTML, CSS, C#, Win Form App, Social Media, GamePlays... https://www.youtube.com/dilipmjgangwar
Every alphabet has its own sound as like "T" when we write Top we don't need a vowel to make sound of "e" so we write directly "Top" and the o overlap the "e" sound. But in the Tea we need two vowels separate vowel for "e" sound. The same case in q"u" when we write the, we need two vowels separate vowel for "u" sound. But when we don't need "u" sound , we can write the word like QWERTY. Conclusion is this we can't use alphabet's successor vowel sound using it in a word we write vowel for that sound.
Thank You So Much Friends
Go to HindiTechSirji for Tech Tutorial of {Word, Excel, Powerpoint, HTML, CSS, C#, Win Form App, Social Media, GamePlays... https://www.youtube.com/dilipmjgangwar
HTML Part 6
HTML List,
ul,
ol,
dl,
Unordered list,
List-style-type,
Ordered list,
Description list,
Child elements,
dt,
data term,
dd,
Data description,
a,
href,
target,
Link,
Hyperlink,
audio,
video,
audio src,
audio loop,
audio controls,
audio autoplay,
source child element,
source, type,
video src,
video loop,
video controls,
video
autoplay
ul,
ol,
dl,
Unordered list,
List-style-type,
Ordered list,
Description list,
Child elements,
dt,
data term,
dd,
Data description,
a,
href,
target,
Link,
Hyperlink,
audio,
video,
audio src,
audio loop,
audio controls,
audio autoplay,
source child element,
source, type,
video src,
video loop,
video controls,
video
autoplay
Part 32 C# Exception Handling 1
What is Exception,
difference between compile & Runtime time error,
Exception Swallowing using Try catch & Finally,
Exception Classes SystemException,
ApplicationException,
IndexOutOfRangeException,
ArrayTypeMismatchException,
NullReferenceException,
DivideByZeroException,
InvalidCastException,
OutOfMemoryException,
StackOverflowException,
Use of throw,
Creating Custom or User Defined Exceptions,
IOException class,
What is Exception Handling Abuse and how Prevent them
Part 31 C# Inheritance
What is inheritance,
Inheritance a Pillar of OOPS,
Why is inheritance,
Advantage of inheritance,
Code Reuse,
Less Error Prompting,
Increase Code Manageability,
inheritance with example,
Comparisons with other platforms,
Multiple & Multilevel Inheritance,
Base keyword,
Role of access modifiers in Inheritance
Part 30 C# Access Specifiers 3
Access Specifiers,
data type,
data members,
Difference between types & Members,
public Access Modifiers,
private Access Modifiers,
Internal Access Modifiers,
Protected Access Modifiers,
Protected Internal Access Specifiers,
.sln,
Solution,
Project,
what is .exe,
what is .dll,
what is Assembly,
types are Assemblies,
.dll for Web App & Class Lib,
.exe for Desktop App,
Derived type object,
Base keyword, this keyword
Subscribe to:
Posts (Atom)